Programme carte strategie (disco)

Dependencies:   mbed SerialHalfDuplex SDFileSystem DISCO-F469NI_portrait liaison_Bluetooth ident_crac

Committer:
Sitkah
Date:
Wed May 02 20:40:57 2018 +0000
Revision:
36:6dd30780bd8e
Parent:
35:742dc6b200b0
Child:
37:fca332b64b42
Recalage en une fois

Who changed what in which revision?

UserRevisionLine numberNew 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 36:6dd30780bd8e 7 /////////////////////ROBOTS/////////////////////////////////////////////
Sitkah 36:6dd30780bd8e 8 #ifdef ROBOT_BIG
Sitkah 36:6dd30780bd8e 9 S_obstacle robot{
Sitkah 36:6dd30780bd8e 10 0,
Sitkah 36:6dd30780bd8e 11 0,
Sitkah 36:6dd30780bd8e 12 6,
Sitkah 36:6dd30780bd8e 13 6,
Sitkah 36:6dd30780bd8e 14 0,
Sitkah 36:6dd30780bd8e 15 0,
Sitkah 36:6dd30780bd8e 16 };
Sitkah 36:6dd30780bd8e 17 #else
Sitkah 36:6dd30780bd8e 18 S_obstacle robot{
Sitkah 36:6dd30780bd8e 19 210,
Sitkah 36:6dd30780bd8e 20 285,
Sitkah 36:6dd30780bd8e 21 4,
Sitkah 36:6dd30780bd8e 22 4,
Sitkah 36:6dd30780bd8e 23 0,
Sitkah 36:6dd30780bd8e 24 0,
Sitkah 36:6dd30780bd8e 25 };
Sitkah 36:6dd30780bd8e 26 #endif
Sitkah 35:742dc6b200b0 27 /////////////////////LISTE DES OBSTACLES/////////////////////////////////
Sitkah 35:742dc6b200b0 28 S_obstacle bloc1{
Sitkah 35:742dc6b200b0 29 500, //x
Sitkah 35:742dc6b200b0 30 800, //y
Sitkah 35:742dc6b200b0 31 2, //largeur axe X
Sitkah 35:742dc6b200b0 32 2, //longueur axe Y
Sitkah 35:742dc6b200b0 33 1, //danger
Sitkah 35:742dc6b200b0 34 0, //rayonnement distance à laquelle il y a un possible danger
Sitkah 35:742dc6b200b0 35 };
Sitkah 35:742dc6b200b0 36
Sitkah 35:742dc6b200b0 37 S_obstacle bloc2{
Sitkah 35:742dc6b200b0 38 500, //x
Sitkah 35:742dc6b200b0 39 2150, //y
Sitkah 35:742dc6b200b0 40 2, //largeur axe X
Sitkah 35:742dc6b200b0 41 2, //longueur axe Y
Sitkah 35:742dc6b200b0 42 1, //danger
Sitkah 35:742dc6b200b0 43 0, //rayonnement distance à laquelle il y a un possible danger
Sitkah 35:742dc6b200b0 44 };
Sitkah 35:742dc6b200b0 45
Sitkah 35:742dc6b200b0 46 S_obstacle bloc3{
Sitkah 35:742dc6b200b0 47 1100, //x
Sitkah 35:742dc6b200b0 48 200, //y
Sitkah 35:742dc6b200b0 49 2, //largeur axe X
Sitkah 35:742dc6b200b0 50 2, //longueur axe Y
Sitkah 35:742dc6b200b0 51 10, //danger
Sitkah 35:742dc6b200b0 52 0, //rayonnement distance à laquelle il y a un possible danger
Sitkah 35:742dc6b200b0 53 };
Sitkah 35:742dc6b200b0 54
Sitkah 35:742dc6b200b0 55 S_obstacle bloc4{
Sitkah 35:742dc6b200b0 56 1100, //x
Sitkah 35:742dc6b200b0 57 2600, //y
Sitkah 35:742dc6b200b0 58 2, //largeur axe X
Sitkah 35:742dc6b200b0 59 2, //longueur axe Y
Sitkah 35:742dc6b200b0 60 1, //danger
Sitkah 35:742dc6b200b0 61 0, //rayonnement distance à laquelle il y a un possible danger
Sitkah 35:742dc6b200b0 62 };
Sitkah 35:742dc6b200b0 63
Sitkah 35:742dc6b200b0 64 S_obstacle bloc5{
Sitkah 35:742dc6b200b0 65 1400, //x
Sitkah 35:742dc6b200b0 66 1000, //y
Sitkah 35:742dc6b200b0 67 2, //largeur axe X
Sitkah 35:742dc6b200b0 68 2, //longueur axe Y
Sitkah 35:742dc6b200b0 69 1, //danger
Sitkah 35:742dc6b200b0 70 0, //rayonnement distance à laquelle il y a un possible danger
Sitkah 35:742dc6b200b0 71 };
Sitkah 35:742dc6b200b0 72
Sitkah 35:742dc6b200b0 73 S_obstacle bloc6{
Sitkah 35:742dc6b200b0 74 1400, //x
Sitkah 35:742dc6b200b0 75 1800, //y
Sitkah 35:742dc6b200b0 76 2, //largeur axe X
Sitkah 35:742dc6b200b0 77 2, //longueur axe Y
Sitkah 35:742dc6b200b0 78 1, //danger
Sitkah 35:742dc6b200b0 79 0, //rayonnement distance à laquelle il y a un possible danger
Sitkah 35:742dc6b200b0 80 };
Sitkah 35:742dc6b200b0 81
Sitkah 36:6dd30780bd8e 82 S_obstacle liste_objets[6]={bloc1,bloc2,bloc3,bloc4,bloc5,bloc6};
Sitkah 35:742dc6b200b0 83
Sitkah 36:6dd30780bd8e 84
Sitkah 35:742dc6b200b0 85
Sitkah 36:6dd30780bd8e 86 void Terrain_init(char **Table){
Sitkah 35:742dc6b200b0 87 int x,y;
Sitkah 35:742dc6b200b0 88 for(x=0;x<TAILLE_TABLE_X/TAILLE_CELLULE;x++){
Sitkah 35:742dc6b200b0 89 for(y=0;y<TAILLE_TABLE_Y/TAILLE_CELLULE;y++){
Sitkah 36:6dd30780bd8e 90 Table[x][y]=1;
Sitkah 35:742dc6b200b0 91 }
Sitkah 35:742dc6b200b0 92 }
Sitkah 35:742dc6b200b0 93 }
Sitkah 36:6dd30780bd8e 94
Sitkah 36:6dd30780bd8e 95 void Terrain_actualisation(char **Table, struct S_obstacle *liste_objet){
Sitkah 36:6dd30780bd8e 96 int x=0,y=0,i=0;
Sitkah 36:6dd30780bd8e 97 x=liste_objet[i].x/TAILLE_CELLULE;
Sitkah 36:6dd30780bd8e 98 y=liste_objet[i].y/TAILLE_CELLULE;
Sitkah 35:742dc6b200b0 99
Sitkah 35:742dc6b200b0 100 for(i=0; i<nb_objets;i++){
Sitkah 35:742dc6b200b0 101 while(x<(x+liste_objet[i].largeur)){
Sitkah 36:6dd30780bd8e 102
Sitkah 36:6dd30780bd8e 103 y=liste_objet[i].y/TAILLE_CELLULE;
Sitkah 36:6dd30780bd8e 104
Sitkah 35:742dc6b200b0 105 while(y<(y+liste_objet[i].longueur)){
Sitkah 35:742dc6b200b0 106 Table[x][y]=liste_objet[i].danger;
Sitkah 35:742dc6b200b0 107 y++;
Sitkah 35:742dc6b200b0 108 }
Sitkah 35:742dc6b200b0 109 x++;
Sitkah 35:742dc6b200b0 110 }
Sitkah 36:6dd30780bd8e 111 }
Sitkah 36:6dd30780bd8e 112 }
Sitkah 36:6dd30780bd8e 113
Sitkah 36:6dd30780bd8e 114 void Actualisation_robot(short x,short y, short theta){
Sitkah 36:6dd30780bd8e 115 robot.x=x;
Sitkah 36:6dd30780bd8e 116 robot.y=y;
Sitkah 36:6dd30780bd8e 117 }
Sitkah 36:6dd30780bd8e 118
Sitkah 36:6dd30780bd8e 119
Sitkah 36:6dd30780bd8e 120 void Actualisation_position(char **Table){
Sitkah 36:6dd30780bd8e 121 short x,y;
Sitkah 36:6dd30780bd8e 122 #ifdef ROBOT_SMALL
Sitkah 36:6dd30780bd8e 123 x=(robot.x-115)/TAILLE_CELLULE;
Sitkah 36:6dd30780bd8e 124 y=(robot.y-115)/TAILLE_CELLULE;
Sitkah 36:6dd30780bd8e 125 #else
Sitkah 36:6dd30780bd8e 126 x=(robot.x-185)/TAILLE_CELLULE;
Sitkah 36:6dd30780bd8e 127 y=(robot.y-185)/TAILLE_CELLULE;
Sitkah 36:6dd30780bd8e 128 #endif
Sitkah 36:6dd30780bd8e 129 while(x<(x+robot.largeur)){
Sitkah 36:6dd30780bd8e 130 y=robot.y/TAILLE_CELLULE;
Sitkah 36:6dd30780bd8e 131
Sitkah 36:6dd30780bd8e 132 while(y<(y+robot.longueur)){
Sitkah 36:6dd30780bd8e 133 Table[x][y]=robot.danger;
Sitkah 36:6dd30780bd8e 134 y++;
Sitkah 36:6dd30780bd8e 135 }
Sitkah 36:6dd30780bd8e 136 x++;
Sitkah 36:6dd30780bd8e 137 }
Sitkah 36:6dd30780bd8e 138 }
Sitkah 36:6dd30780bd8e 139
Sitkah 36:6dd30780bd8e 140 void Actualisation_objets(char **Table,S_obstacle bloc, short x_bloc, short y_bloc){ //déplacement des cubes
Sitkah 36:6dd30780bd8e 141 int x=0,y=0;
Sitkah 36:6dd30780bd8e 142 x=bloc.x/TAILLE_CELLULE;
Sitkah 36:6dd30780bd8e 143 y=bloc.y/TAILLE_CELLULE;
Sitkah 36:6dd30780bd8e 144
Sitkah 36:6dd30780bd8e 145 while(x<(x+bloc.largeur)){
Sitkah 36:6dd30780bd8e 146
Sitkah 36:6dd30780bd8e 147 y=bloc.y/TAILLE_CELLULE;
Sitkah 36:6dd30780bd8e 148
Sitkah 36:6dd30780bd8e 149 while(y<(y+bloc.longueur)){
Sitkah 36:6dd30780bd8e 150 Table[x][y]=1;
Sitkah 36:6dd30780bd8e 151 y++;
Sitkah 36:6dd30780bd8e 152 }
Sitkah 36:6dd30780bd8e 153 x++;
Sitkah 35:742dc6b200b0 154 }
Sitkah 35:742dc6b200b0 155
Sitkah 36:6dd30780bd8e 156 bloc.x=x_bloc;
Sitkah 36:6dd30780bd8e 157 bloc.y=y_bloc;
Sitkah 36:6dd30780bd8e 158 x=bloc.x/TAILLE_CELLULE;
Sitkah 36:6dd30780bd8e 159 y=bloc.y/TAILLE_CELLULE;
Sitkah 36:6dd30780bd8e 160
Sitkah 36:6dd30780bd8e 161 while(x<(x+bloc.largeur)){
Sitkah 35:742dc6b200b0 162
Sitkah 36:6dd30780bd8e 163 y=bloc.y/TAILLE_CELLULE;
Sitkah 36:6dd30780bd8e 164
Sitkah 36:6dd30780bd8e 165 while(y<(y+bloc.longueur)){
Sitkah 36:6dd30780bd8e 166 Table[x][y]=1;
Sitkah 36:6dd30780bd8e 167 y++;
Sitkah 36:6dd30780bd8e 168 }
Sitkah 36:6dd30780bd8e 169 x++;
Sitkah 36:6dd30780bd8e 170 }
Sitkah 36:6dd30780bd8e 171 }
Sitkah 36:6dd30780bd8e 172
Sitkah 36:6dd30780bd8e 173