carte_strategie_2019

Dependencies:   mbed SerialHalfDuplex SDFileSystem DISCO-F469NI_portrait liaison_Bluetooth ident_crac

Revision:
36:6dd30780bd8e
Parent:
35:742dc6b200b0
Child:
37:fca332b64b42
diff -r 742dc6b200b0 -r 6dd30780bd8e Evitement/Evitement.cpp
--- a/Evitement/Evitement.cpp	Tue May 01 13:25:42 2018 +0000
+++ b/Evitement/Evitement.cpp	Wed May 02 20:40:57 2018 +0000
@@ -4,10 +4,26 @@
 #include <string.h>
 #include <math.h>
 
-
-
-
-
+/////////////////////ROBOTS/////////////////////////////////////////////
+#ifdef ROBOT_BIG
+    S_obstacle robot{
+        0,
+        0,
+        6,
+        6,
+        0,
+        0,
+    };
+#else
+    S_obstacle robot{
+        210,
+        285,
+        4,
+        4,
+        0,
+        0,
+    };
+#endif
 /////////////////////LISTE DES OBSTACLES/////////////////////////////////
 S_obstacle bloc1{
     500,  //x
@@ -62,72 +78,96 @@
     1,  //danger 
     0,  //rayonnement distance à laquelle il y a un possible danger
 };
-/*void initialisation_du_tableau(unsigned char **Table) //TABLEAU DE MERDE
-{
-    short i = 0;
-    
-    Table = (char*)malloc(sizeof(char**) * 2);
-        
-    /*Table = calloc(1, sizeof(*char) );
-    
-    while(i < (TAILLE_TABLE_Y/TAILLE_CELLULE) )
-    {
-        Table[i] = calloc((TAILLE_TABLE_X/TAILLE_CELLULE), sizeof(*char));        
-        i++;
-    }
-    int i;
-    int * tableauDePtr[30];
-    int (*tableau)[4];
 
-    tableau = malloc(5 * sizeof(*tableau));
+S_obstacle liste_objets[6]={bloc1,bloc2,bloc3,bloc4,bloc5,bloc6};
 
-    
-    //---Allocation-----
-    for(i=0 ; i < 5 ; i++){
-           tableauDePtr[i] = malloc(20 * sizeof(tableau[0]));
-           if(tableauDePtr[i] == NULL){    //En cas d'erreur d'allocation
-                //N'oubliez pas de notifier l'erreur
-                for(i=i-1 ; i >= 0 ; i--)  //Libération de l'espace déjà alloué
-                     free(tableauDePtr[i]);
-    
-                exit(EXIT_FAILURE);
-           }
-    }
-    
-    //---Libération en cas d'allocation réussie-----
-    for(i=0 ; i < 5 ; i++){
-           free(tableauDePtr[i]);
-    }
+
 
-}*/
-void Terrain_clear(char **Table){
+void Terrain_init(char **Table){
     int x,y;
     for(x=0;x<TAILLE_TABLE_X/TAILLE_CELLULE;x++){
         for(y=0;y<TAILLE_TABLE_Y/TAILLE_CELLULE;y++){
-            Table[x][y]=0;
+            Table[x][y]=1;
         }
     }
 }
-void Terrain_init(char **Table, struct S_obstacle *liste_objet){
-    int x,y,i;
+
+void Terrain_actualisation(char **Table, struct S_obstacle *liste_objet){
+    int x=0,y=0,i=0;
+    x=liste_objet[i].x/TAILLE_CELLULE;
+    y=liste_objet[i].y/TAILLE_CELLULE;
     
-    /*for(y=0;y<TAILLE_TABLE_Y/TAILLE_CELLULE;y++){
-        for(x=0;x<TAILLE_TABLE_YxTAILLE_CELLULE;x++){
-            if(liste_objet[i].x==x && liste_objet[i].y==y){
-                while(y<(y+largeur)){
-     */
     for(i=0; i<nb_objets;i++){
         while(x<(x+liste_objet[i].largeur)){ 
+        
+            y=liste_objet[i].y/TAILLE_CELLULE;
+            
             while(y<(y+liste_objet[i].longueur)){ 
                 Table[x][y]=liste_objet[i].danger;
                 y++;
             }
             x++;
         }
+    }   
+}
+
+void Actualisation_robot(short x,short y, short theta){
+    robot.x=x;
+    robot.y=y;
+}
+    
+
+void Actualisation_position(char **Table){
+    short x,y;
+    #ifdef ROBOT_SMALL
+        x=(robot.x-115)/TAILLE_CELLULE;
+        y=(robot.y-115)/TAILLE_CELLULE;
+    #else
+        x=(robot.x-185)/TAILLE_CELLULE;
+        y=(robot.y-185)/TAILLE_CELLULE;
+    #endif
+    while(x<(x+robot.largeur)){ 
+        y=robot.y/TAILLE_CELLULE;
+            
+        while(y<(y+robot.longueur)){ 
+            Table[x][y]=robot.danger;
+            y++;
+        }
+        x++;
+    }
+}
+
+void Actualisation_objets(char **Table,S_obstacle bloc, short x_bloc, short y_bloc){    //déplacement des cubes
+    int x=0,y=0;
+    x=bloc.x/TAILLE_CELLULE;
+    y=bloc.y/TAILLE_CELLULE;
+    
+    while(x<(x+bloc.largeur)){ 
+    
+        y=bloc.y/TAILLE_CELLULE;
+        
+        while(y<(y+bloc.longueur)){ 
+            Table[x][y]=1;
+            y++;
+        }
+        x++;
     }
     
-                  
-                
+    bloc.x=x_bloc;  
+    bloc.y=y_bloc;  
+    x=bloc.x/TAILLE_CELLULE;
+    y=bloc.y/TAILLE_CELLULE;
+    
+    while(x<(x+bloc.largeur)){ 
     
-    
-}
\ No newline at end of file
+        y=bloc.y/TAILLE_CELLULE;
+        
+        while(y<(y+bloc.longueur)){ 
+            Table[x][y]=1;
+            y++;
+        }
+        x++;
+    }
+}    
+
+