v2019

Dependencies:   CRAC-Strat_2019 SerialHalfDuplex SDFileSystem DISCO-F469NI_portrait liaison_Bluetooth ident_crac

Dependents:   Codeprincipal_2019 CRAC-Strat_2019

Evitement/Evitement.cpp

Committer:
Sitkah
Date:
2018-05-01
Revision:
35:742dc6b200b0
Child:
36:6dd30780bd8e

File content as of revision 35:742dc6b200b0:

#include "Evitement.h"

#include <stdlib.h>
#include <string.h>
#include <math.h>





/////////////////////LISTE DES OBSTACLES/////////////////////////////////
S_obstacle bloc1{
    500,  //x
    800,  //y
    2,  //largeur axe X
    2,  //longueur axe Y
    1,  //danger 
    0,  //rayonnement distance à laquelle il y a un possible danger
};

S_obstacle bloc2{
    500,  //x
    2150,  //y
    2,  //largeur axe X
    2,  //longueur axe Y
    1,  //danger 
    0,  //rayonnement distance à laquelle il y a un possible danger
};

S_obstacle bloc3{
    1100,  //x
    200,  //y
    2,  //largeur axe X
    2,  //longueur axe Y
10,  //danger 
    0,  //rayonnement distance à laquelle il y a un possible danger
};

S_obstacle bloc4{
    1100,  //x
    2600,  //y
    2,  //largeur axe X
    2,  //longueur axe Y
    1,  //danger 
    0,  //rayonnement distance à laquelle il y a un possible danger
};

S_obstacle bloc5{
    1400,  //x
    1000,  //y
    2,  //largeur axe X
    2,  //longueur axe Y
    1,  //danger 
    0,  //rayonnement distance à laquelle il y a un possible danger
};

S_obstacle bloc6{
    1400,  //x
    1800,  //y
    2,  //largeur axe X
    2,  //longueur axe Y
    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));

    
    //---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){
    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;
        }
    }
}
void Terrain_init(char **Table, struct S_obstacle *liste_objet){
    int x,y,i;
    
    /*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)){ 
            while(y<(y+liste_objet[i].longueur)){ 
                Table[x][y]=liste_objet[i].danger;
                y++;
            }
            x++;
        }
    }
    
                  
                
    
    
}