carte_strategie_2019
Dependencies: mbed SerialHalfDuplex SDFileSystem DISCO-F469NI_portrait liaison_Bluetooth ident_crac
Evitement/Evitement.cpp@35:742dc6b200b0, 2018-05-01 (annotated)
- Committer:
- Sitkah
- Date:
- Tue May 01 13:25:42 2018 +0000
- Revision:
- 35:742dc6b200b0
- Child:
- 36:6dd30780bd8e
bug turn
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Sitkah | 35:742dc6b200b0 | 1 | #include "Evitement.h" |
Sitkah | 35:742dc6b200b0 | 2 | |
Sitkah | 35:742dc6b200b0 | 3 | #include <stdlib.h> |
Sitkah | 35:742dc6b200b0 | 4 | #include <string.h> |
Sitkah | 35:742dc6b200b0 | 5 | #include <math.h> |
Sitkah | 35:742dc6b200b0 | 6 | |
Sitkah | 35:742dc6b200b0 | 7 | |
Sitkah | 35:742dc6b200b0 | 8 | |
Sitkah | 35:742dc6b200b0 | 9 | |
Sitkah | 35:742dc6b200b0 | 10 | |
Sitkah | 35:742dc6b200b0 | 11 | /////////////////////LISTE DES OBSTACLES///////////////////////////////// |
Sitkah | 35:742dc6b200b0 | 12 | S_obstacle bloc1{ |
Sitkah | 35:742dc6b200b0 | 13 | 500, //x |
Sitkah | 35:742dc6b200b0 | 14 | 800, //y |
Sitkah | 35:742dc6b200b0 | 15 | 2, //largeur axe X |
Sitkah | 35:742dc6b200b0 | 16 | 2, //longueur axe Y |
Sitkah | 35:742dc6b200b0 | 17 | 1, //danger |
Sitkah | 35:742dc6b200b0 | 18 | 0, //rayonnement distance à laquelle il y a un possible danger |
Sitkah | 35:742dc6b200b0 | 19 | }; |
Sitkah | 35:742dc6b200b0 | 20 | |
Sitkah | 35:742dc6b200b0 | 21 | S_obstacle bloc2{ |
Sitkah | 35:742dc6b200b0 | 22 | 500, //x |
Sitkah | 35:742dc6b200b0 | 23 | 2150, //y |
Sitkah | 35:742dc6b200b0 | 24 | 2, //largeur axe X |
Sitkah | 35:742dc6b200b0 | 25 | 2, //longueur axe Y |
Sitkah | 35:742dc6b200b0 | 26 | 1, //danger |
Sitkah | 35:742dc6b200b0 | 27 | 0, //rayonnement distance à laquelle il y a un possible danger |
Sitkah | 35:742dc6b200b0 | 28 | }; |
Sitkah | 35:742dc6b200b0 | 29 | |
Sitkah | 35:742dc6b200b0 | 30 | S_obstacle bloc3{ |
Sitkah | 35:742dc6b200b0 | 31 | 1100, //x |
Sitkah | 35:742dc6b200b0 | 32 | 200, //y |
Sitkah | 35:742dc6b200b0 | 33 | 2, //largeur axe X |
Sitkah | 35:742dc6b200b0 | 34 | 2, //longueur axe Y |
Sitkah | 35:742dc6b200b0 | 35 | 10, //danger |
Sitkah | 35:742dc6b200b0 | 36 | 0, //rayonnement distance à laquelle il y a un possible danger |
Sitkah | 35:742dc6b200b0 | 37 | }; |
Sitkah | 35:742dc6b200b0 | 38 | |
Sitkah | 35:742dc6b200b0 | 39 | S_obstacle bloc4{ |
Sitkah | 35:742dc6b200b0 | 40 | 1100, //x |
Sitkah | 35:742dc6b200b0 | 41 | 2600, //y |
Sitkah | 35:742dc6b200b0 | 42 | 2, //largeur axe X |
Sitkah | 35:742dc6b200b0 | 43 | 2, //longueur axe Y |
Sitkah | 35:742dc6b200b0 | 44 | 1, //danger |
Sitkah | 35:742dc6b200b0 | 45 | 0, //rayonnement distance à laquelle il y a un possible danger |
Sitkah | 35:742dc6b200b0 | 46 | }; |
Sitkah | 35:742dc6b200b0 | 47 | |
Sitkah | 35:742dc6b200b0 | 48 | S_obstacle bloc5{ |
Sitkah | 35:742dc6b200b0 | 49 | 1400, //x |
Sitkah | 35:742dc6b200b0 | 50 | 1000, //y |
Sitkah | 35:742dc6b200b0 | 51 | 2, //largeur axe X |
Sitkah | 35:742dc6b200b0 | 52 | 2, //longueur axe Y |
Sitkah | 35:742dc6b200b0 | 53 | 1, //danger |
Sitkah | 35:742dc6b200b0 | 54 | 0, //rayonnement distance à laquelle il y a un possible danger |
Sitkah | 35:742dc6b200b0 | 55 | }; |
Sitkah | 35:742dc6b200b0 | 56 | |
Sitkah | 35:742dc6b200b0 | 57 | S_obstacle bloc6{ |
Sitkah | 35:742dc6b200b0 | 58 | 1400, //x |
Sitkah | 35:742dc6b200b0 | 59 | 1800, //y |
Sitkah | 35:742dc6b200b0 | 60 | 2, //largeur axe X |
Sitkah | 35:742dc6b200b0 | 61 | 2, //longueur axe Y |
Sitkah | 35:742dc6b200b0 | 62 | 1, //danger |
Sitkah | 35:742dc6b200b0 | 63 | 0, //rayonnement distance à laquelle il y a un possible danger |
Sitkah | 35:742dc6b200b0 | 64 | }; |
Sitkah | 35:742dc6b200b0 | 65 | /*void initialisation_du_tableau(unsigned char **Table) //TABLEAU DE MERDE |
Sitkah | 35:742dc6b200b0 | 66 | { |
Sitkah | 35:742dc6b200b0 | 67 | short i = 0; |
Sitkah | 35:742dc6b200b0 | 68 | |
Sitkah | 35:742dc6b200b0 | 69 | Table = (char*)malloc(sizeof(char**) * 2); |
Sitkah | 35:742dc6b200b0 | 70 | |
Sitkah | 35:742dc6b200b0 | 71 | /*Table = calloc(1, sizeof(*char) ); |
Sitkah | 35:742dc6b200b0 | 72 | |
Sitkah | 35:742dc6b200b0 | 73 | while(i < (TAILLE_TABLE_Y/TAILLE_CELLULE) ) |
Sitkah | 35:742dc6b200b0 | 74 | { |
Sitkah | 35:742dc6b200b0 | 75 | Table[i] = calloc((TAILLE_TABLE_X/TAILLE_CELLULE), sizeof(*char)); |
Sitkah | 35:742dc6b200b0 | 76 | i++; |
Sitkah | 35:742dc6b200b0 | 77 | } |
Sitkah | 35:742dc6b200b0 | 78 | int i; |
Sitkah | 35:742dc6b200b0 | 79 | int * tableauDePtr[30]; |
Sitkah | 35:742dc6b200b0 | 80 | int (*tableau)[4]; |
Sitkah | 35:742dc6b200b0 | 81 | |
Sitkah | 35:742dc6b200b0 | 82 | tableau = malloc(5 * sizeof(*tableau)); |
Sitkah | 35:742dc6b200b0 | 83 | |
Sitkah | 35:742dc6b200b0 | 84 | |
Sitkah | 35:742dc6b200b0 | 85 | //---Allocation----- |
Sitkah | 35:742dc6b200b0 | 86 | for(i=0 ; i < 5 ; i++){ |
Sitkah | 35:742dc6b200b0 | 87 | tableauDePtr[i] = malloc(20 * sizeof(tableau[0])); |
Sitkah | 35:742dc6b200b0 | 88 | if(tableauDePtr[i] == NULL){ //En cas d'erreur d'allocation |
Sitkah | 35:742dc6b200b0 | 89 | //N'oubliez pas de notifier l'erreur |
Sitkah | 35:742dc6b200b0 | 90 | for(i=i-1 ; i >= 0 ; i--) //Libération de l'espace déjà alloué |
Sitkah | 35:742dc6b200b0 | 91 | free(tableauDePtr[i]); |
Sitkah | 35:742dc6b200b0 | 92 | |
Sitkah | 35:742dc6b200b0 | 93 | exit(EXIT_FAILURE); |
Sitkah | 35:742dc6b200b0 | 94 | } |
Sitkah | 35:742dc6b200b0 | 95 | } |
Sitkah | 35:742dc6b200b0 | 96 | |
Sitkah | 35:742dc6b200b0 | 97 | //---Libération en cas d'allocation réussie----- |
Sitkah | 35:742dc6b200b0 | 98 | for(i=0 ; i < 5 ; i++){ |
Sitkah | 35:742dc6b200b0 | 99 | free(tableauDePtr[i]); |
Sitkah | 35:742dc6b200b0 | 100 | } |
Sitkah | 35:742dc6b200b0 | 101 | |
Sitkah | 35:742dc6b200b0 | 102 | }*/ |
Sitkah | 35:742dc6b200b0 | 103 | void Terrain_clear(char **Table){ |
Sitkah | 35:742dc6b200b0 | 104 | int x,y; |
Sitkah | 35:742dc6b200b0 | 105 | for(x=0;x<TAILLE_TABLE_X/TAILLE_CELLULE;x++){ |
Sitkah | 35:742dc6b200b0 | 106 | for(y=0;y<TAILLE_TABLE_Y/TAILLE_CELLULE;y++){ |
Sitkah | 35:742dc6b200b0 | 107 | Table[x][y]=0; |
Sitkah | 35:742dc6b200b0 | 108 | } |
Sitkah | 35:742dc6b200b0 | 109 | } |
Sitkah | 35:742dc6b200b0 | 110 | } |
Sitkah | 35:742dc6b200b0 | 111 | void Terrain_init(char **Table, struct S_obstacle *liste_objet){ |
Sitkah | 35:742dc6b200b0 | 112 | int x,y,i; |
Sitkah | 35:742dc6b200b0 | 113 | |
Sitkah | 35:742dc6b200b0 | 114 | /*for(y=0;y<TAILLE_TABLE_Y/TAILLE_CELLULE;y++){ |
Sitkah | 35:742dc6b200b0 | 115 | for(x=0;x<TAILLE_TABLE_YxTAILLE_CELLULE;x++){ |
Sitkah | 35:742dc6b200b0 | 116 | if(liste_objet[i].x==x && liste_objet[i].y==y){ |
Sitkah | 35:742dc6b200b0 | 117 | while(y<(y+largeur)){ |
Sitkah | 35:742dc6b200b0 | 118 | */ |
Sitkah | 35:742dc6b200b0 | 119 | for(i=0; i<nb_objets;i++){ |
Sitkah | 35:742dc6b200b0 | 120 | while(x<(x+liste_objet[i].largeur)){ |
Sitkah | 35:742dc6b200b0 | 121 | while(y<(y+liste_objet[i].longueur)){ |
Sitkah | 35:742dc6b200b0 | 122 | Table[x][y]=liste_objet[i].danger; |
Sitkah | 35:742dc6b200b0 | 123 | y++; |
Sitkah | 35:742dc6b200b0 | 124 | } |
Sitkah | 35:742dc6b200b0 | 125 | x++; |
Sitkah | 35:742dc6b200b0 | 126 | } |
Sitkah | 35:742dc6b200b0 | 127 | } |
Sitkah | 35:742dc6b200b0 | 128 | |
Sitkah | 35:742dc6b200b0 | 129 | |
Sitkah | 35:742dc6b200b0 | 130 | |
Sitkah | 35:742dc6b200b0 | 131 | |
Sitkah | 35:742dc6b200b0 | 132 | |
Sitkah | 35:742dc6b200b0 | 133 | } |