![](/media/cache/profiles/4b0986230d9d7aded7f0c24033d221d4.jpg.50x50_q85.jpg)
Programme de contrôle de l'octopode 4DOF, Theraphosa-Salconi.
CtrlBridge
- fonction quelquonque pour communiquer avec les module
- fonction quelquonque pour faire des recherche dans les module dispo
- autre fonction pour jouer avec MemRegistre
Version 1.2.0
- Ajout d'un mode de simulation pour tester le code avec seulement un contrôleur stm32
labyrinthe.cpp@35:d81f6b927932, 2015-09-12 (annotated)
- Committer:
- salco
- Date:
- Sat Sep 12 21:34:57 2015 +0000
- Revision:
- 35:d81f6b927932
- Parent:
- 28:ac5c6350ed9a
- Child:
- 36:474d4795aafa
modification du labyrithe et test du doxygen.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
salco | 35:d81f6b927932 | 1 | /** |
salco | 35:d81f6b927932 | 2 | * @file labyrinthe.cpp |
salco | 35:d81f6b927932 | 3 | * @brief Regroupement de fonction pour enregistrer le millieu en 2D. |
salco | 35:d81f6b927932 | 4 | * @author Salco |
salco | 35:d81f6b927932 | 5 | * @version 2.00 |
salco | 35:d81f6b927932 | 6 | * @date 11 mars 2015 |
salco | 35:d81f6b927932 | 7 | */ |
salco | 28:ac5c6350ed9a | 8 | #include "labyrinthe.h" |
salco | 28:ac5c6350ed9a | 9 | |
salco | 28:ac5c6350ed9a | 10 | |
salco | 28:ac5c6350ed9a | 11 | Labyrinthe::Labyrinthe() |
salco | 28:ac5c6350ed9a | 12 | { |
salco | 28:ac5c6350ed9a | 13 | direction=0; |
salco | 28:ac5c6350ed9a | 14 | mapDuLabyrinthe.clear(); |
salco | 28:ac5c6350ed9a | 15 | addMap(0,0); |
salco | 28:ac5c6350ed9a | 16 | m_posX=0; |
salco | 28:ac5c6350ed9a | 17 | m_posY=0; |
salco | 28:ac5c6350ed9a | 18 | } |
salco | 28:ac5c6350ed9a | 19 | |
salco | 28:ac5c6350ed9a | 20 | Labyrinthe::~Labyrinthe() |
salco | 28:ac5c6350ed9a | 21 | { |
salco | 28:ac5c6350ed9a | 22 | } |
salco | 28:ac5c6350ed9a | 23 | |
salco | 28:ac5c6350ed9a | 24 | char Labyrinthe::getCoordoner(char &x, char &y) |
salco | 28:ac5c6350ed9a | 25 | { |
salco | 28:ac5c6350ed9a | 26 | char result; |
salco | 28:ac5c6350ed9a | 27 | char newPosX,newPosY; |
salco | 28:ac5c6350ed9a | 28 | newPosX = 3*(x/3); // je veux le nobre de fois quil a fait un tours et donc seulment les entier |
salco | 28:ac5c6350ed9a | 29 | newPosY = 3*(y/3); |
salco | 28:ac5c6350ed9a | 30 | |
salco | 28:ac5c6350ed9a | 31 | x = newPosX; |
salco | 28:ac5c6350ed9a | 32 | y = newPosY; |
salco | 28:ac5c6350ed9a | 33 | |
salco | 28:ac5c6350ed9a | 34 | result = 2 + newPosX; |
salco | 28:ac5c6350ed9a | 35 | |
salco | 28:ac5c6350ed9a | 36 | switch(newPosY) { |
salco | 28:ac5c6350ed9a | 37 | case-1: |
salco | 28:ac5c6350ed9a | 38 | result = result + (3*2); |
salco | 28:ac5c6350ed9a | 39 | break; |
salco | 28:ac5c6350ed9a | 40 | |
salco | 28:ac5c6350ed9a | 41 | case 0: |
salco | 28:ac5c6350ed9a | 42 | result = result + (3*1); |
salco | 28:ac5c6350ed9a | 43 | break; |
salco | 28:ac5c6350ed9a | 44 | |
salco | 28:ac5c6350ed9a | 45 | case 1: |
salco | 28:ac5c6350ed9a | 46 | result = result + (3*0); |
salco | 28:ac5c6350ed9a | 47 | break; |
salco | 28:ac5c6350ed9a | 48 | } |
salco | 28:ac5c6350ed9a | 49 | |
salco | 28:ac5c6350ed9a | 50 | debug(DEBUGLABCOORD,"\n\r result: X: %02d Y:%02d",newPosX,newPosY); |
salco | 35:d81f6b927932 | 51 | debug(DEBUGLABCOORD,"\n\r result: :%02d \n\r",result); |
salco | 28:ac5c6350ed9a | 52 | |
salco | 28:ac5c6350ed9a | 53 | return result; |
salco | 28:ac5c6350ed9a | 54 | } |
salco | 28:ac5c6350ed9a | 55 | char Labyrinthe::getCoordoner(void) |
salco | 28:ac5c6350ed9a | 56 | { |
salco | 28:ac5c6350ed9a | 57 | char result=0; |
salco | 28:ac5c6350ed9a | 58 | char newPosX,newPosY; |
salco | 28:ac5c6350ed9a | 59 | |
salco | 28:ac5c6350ed9a | 60 | newPosX = 3*(m_posX/3); // je veux le nobre de fois quil a fait un tours et donc seulment les entier |
salco | 28:ac5c6350ed9a | 61 | newPosY = 3*(m_posY/3); |
salco | 28:ac5c6350ed9a | 62 | |
salco | 28:ac5c6350ed9a | 63 | newPosX = m_posX-newPosX; |
salco | 28:ac5c6350ed9a | 64 | newPosY = m_posY-newPosY; |
salco | 28:ac5c6350ed9a | 65 | |
salco | 28:ac5c6350ed9a | 66 | result = 2 + newPosX; |
salco | 28:ac5c6350ed9a | 67 | |
salco | 28:ac5c6350ed9a | 68 | switch(newPosY) { |
salco | 28:ac5c6350ed9a | 69 | case-1: |
salco | 28:ac5c6350ed9a | 70 | result = result + (3*2); |
salco | 28:ac5c6350ed9a | 71 | break; |
salco | 28:ac5c6350ed9a | 72 | |
salco | 28:ac5c6350ed9a | 73 | case 0: |
salco | 28:ac5c6350ed9a | 74 | result = result + (3*1); |
salco | 28:ac5c6350ed9a | 75 | break; |
salco | 28:ac5c6350ed9a | 76 | |
salco | 28:ac5c6350ed9a | 77 | case 1: |
salco | 28:ac5c6350ed9a | 78 | result = result + (3*0); |
salco | 28:ac5c6350ed9a | 79 | break; |
salco | 28:ac5c6350ed9a | 80 | } |
salco | 28:ac5c6350ed9a | 81 | |
salco | 28:ac5c6350ed9a | 82 | debug(DEBUGLABCOORD,"\n\r result: X: %02d Y:%02d",newPosX,newPosY); |
salco | 35:d81f6b927932 | 83 | debug(DEBUGLABCOORD,"\n\r result: :%02d \n\r",result); |
salco | 28:ac5c6350ed9a | 84 | |
salco | 28:ac5c6350ed9a | 85 | return result; |
salco | 28:ac5c6350ed9a | 86 | } |
salco | 28:ac5c6350ed9a | 87 | |
salco | 35:d81f6b927932 | 88 | string Labyrinthe::showMap(void) |
salco | 28:ac5c6350ed9a | 89 | { |
salco | 28:ac5c6350ed9a | 90 | return showMap(m_posX,m_posY); |
salco | 28:ac5c6350ed9a | 91 | } |
salco | 28:ac5c6350ed9a | 92 | string Labyrinthe::showMap(char x, char y) |
salco | 28:ac5c6350ed9a | 93 | { |
salco | 28:ac5c6350ed9a | 94 | //bool result=false; |
salco | 28:ac5c6350ed9a | 95 | string theMap; |
salco | 28:ac5c6350ed9a | 96 | theMap.clear(); |
salco | 28:ac5c6350ed9a | 97 | /* char newPosX = x; |
salco | 28:ac5c6350ed9a | 98 | char newPosY = y; |
salco | 28:ac5c6350ed9a | 99 | |
salco | 28:ac5c6350ed9a | 100 | getCoordoner(newPosX,newPosY); |
salco | 28:ac5c6350ed9a | 101 | unsigned char templateX,templateY; |
salco | 28:ac5c6350ed9a | 102 | for(int i=0; ((i*DEFAULTLABLEIGHT)<mapDuLabyrinthe.size()) && (!result);i++) |
salco | 28:ac5c6350ed9a | 103 | { |
salco | 28:ac5c6350ed9a | 104 | templateX = (mapDuLabyrinthe[(i*DEFAULTLABLEIGHT)])>>1; |
salco | 28:ac5c6350ed9a | 105 | templateY = ((mapDuLabyrinthe[(i*DEFAULTLABLEIGHT)])&1)<<7; |
salco | 28:ac5c6350ed9a | 106 | templateY += ((mapDuLabyrinthe[(i*DEFAULTLABLEIGHT)+1])>>2); |
salco | 28:ac5c6350ed9a | 107 | |
salco | 28:ac5c6350ed9a | 108 | if((templateX == newPosX) && (templateY == newPosY)) |
salco | 28:ac5c6350ed9a | 109 | { |
salco | 28:ac5c6350ed9a | 110 | result=true; |
salco | 28:ac5c6350ed9a | 111 | theMap.append(1,((mapDuLabyrinthe[(i*DEFAULTLABLEIGHT)+1])& 3)); |
salco | 28:ac5c6350ed9a | 112 | } |
salco | 28:ac5c6350ed9a | 113 | }*/ |
salco | 28:ac5c6350ed9a | 114 | int stringPosition = searchCoord(x,y); |
salco | 28:ac5c6350ed9a | 115 | if(stringPosition != -1) { |
salco | 28:ac5c6350ed9a | 116 | theMap.append(1,((mapDuLabyrinthe[(stringPosition)+1]>>0)& 3)); |
salco | 28:ac5c6350ed9a | 117 | theMap.append(1,((mapDuLabyrinthe[(stringPosition)+2]>>6)& 3)); |
salco | 28:ac5c6350ed9a | 118 | theMap.append(1,((mapDuLabyrinthe[(stringPosition)+2]>>4)& 3)); |
salco | 28:ac5c6350ed9a | 119 | |
salco | 28:ac5c6350ed9a | 120 | theMap.append(1,((mapDuLabyrinthe[(stringPosition)+2]>>2)& 3)); |
salco | 28:ac5c6350ed9a | 121 | theMap.append(1,((mapDuLabyrinthe[(stringPosition)+2]>>0)& 3)); |
salco | 28:ac5c6350ed9a | 122 | theMap.append(1,((mapDuLabyrinthe[(stringPosition)+3]>>6)& 3)); |
salco | 28:ac5c6350ed9a | 123 | |
salco | 28:ac5c6350ed9a | 124 | theMap.append(1,((mapDuLabyrinthe[(stringPosition)+3]>>4)& 3)); |
salco | 28:ac5c6350ed9a | 125 | theMap.append(1,((mapDuLabyrinthe[(stringPosition)+3]>>2)& 3)); |
salco | 28:ac5c6350ed9a | 126 | theMap.append(1,((mapDuLabyrinthe[(stringPosition)+3]>>0)& 3)); |
salco | 28:ac5c6350ed9a | 127 | } |
salco | 35:d81f6b927932 | 128 | |
salco | 35:d81f6b927932 | 129 | #ifdef DEBUG_BOOT_GRAPHICAL_INTERFACE |
salco | 35:d81f6b927932 | 130 | debug("\n\r----------showmap------\n\r"); |
salco | 35:d81f6b927932 | 131 | debug(" map size: %i \n\r",mapDuLabyrinthe.size()); |
salco | 35:d81f6b927932 | 132 | debug(" stringPosition: %i \n\r",stringPosition); |
salco | 35:d81f6b927932 | 133 | if(stringPosition != -1) { |
salco | 35:d81f6b927932 | 134 | debug(" (mapDuLabyrinthe[(stringPosition)+1]>>0): %i &3== %i \n\r",(mapDuLabyrinthe[(stringPosition)+1]>>0),((mapDuLabyrinthe[(stringPosition)+1]>>0)& 3)); |
salco | 35:d81f6b927932 | 135 | debug(" (mapDuLabyrinthe[(stringPosition)+2]>>6): %i &3== %i \n\r",(mapDuLabyrinthe[(stringPosition)+2]>>6),((mapDuLabyrinthe[(stringPosition)+2]>>6)& 3)); |
salco | 35:d81f6b927932 | 136 | debug(" (mapDuLabyrinthe[(stringPosition)+2]>>4): %i &3== %i \n\r",(mapDuLabyrinthe[(stringPosition)+2]>>4),((mapDuLabyrinthe[(stringPosition)+2]>>4)& 3)); |
salco | 35:d81f6b927932 | 137 | debug(" \n\r"); |
salco | 35:d81f6b927932 | 138 | debug(" (mapDuLabyrinthe[(stringPosition)+2]>>2): %i &3== %i \n\r",(mapDuLabyrinthe[(stringPosition)+2]>>2),((mapDuLabyrinthe[(stringPosition)+2]>>2)& 3)); |
salco | 35:d81f6b927932 | 139 | debug(" (mapDuLabyrinthe[(stringPosition)+2]>>0): %i &3== %i \n\r",(mapDuLabyrinthe[(stringPosition)+2]>>0),((mapDuLabyrinthe[(stringPosition)+2]>>0)& 3)); |
salco | 35:d81f6b927932 | 140 | debug(" (mapDuLabyrinthe[(stringPosition)+3]>>6): %i &3== %i \n\r",(mapDuLabyrinthe[(stringPosition)+3]>>6),((mapDuLabyrinthe[(stringPosition)+3]>>6)& 3)); |
salco | 35:d81f6b927932 | 141 | debug(" \n\r"); |
salco | 35:d81f6b927932 | 142 | debug(" (mapDuLabyrinthe[(stringPosition)+3]>>4): %i &3== %i \n\r",(mapDuLabyrinthe[(stringPosition)+3]>>4),((mapDuLabyrinthe[(stringPosition)+3]>>4)& 3)); |
salco | 35:d81f6b927932 | 143 | debug(" (mapDuLabyrinthe[(stringPosition)+3]>>2): %i &3== %i \n\r",(mapDuLabyrinthe[(stringPosition)+3]>>2),((mapDuLabyrinthe[(stringPosition)+3]>>2)& 3)); |
salco | 35:d81f6b927932 | 144 | debug(" (mapDuLabyrinthe[(stringPosition)+3]>>0): %i &3== %i \n\r",(mapDuLabyrinthe[(stringPosition)+3]>>0),((mapDuLabyrinthe[(stringPosition)+3]>>0)& 3)); |
salco | 35:d81f6b927932 | 145 | debug(" \n\r"); |
salco | 35:d81f6b927932 | 146 | } |
salco | 35:d81f6b927932 | 147 | debug("\n\r----------------------\n\r"); |
salco | 35:d81f6b927932 | 148 | #endif |
salco | 28:ac5c6350ed9a | 149 | return theMap; |
salco | 28:ac5c6350ed9a | 150 | } |
salco | 28:ac5c6350ed9a | 151 | |
salco | 28:ac5c6350ed9a | 152 | bool Labyrinthe::updateMap(string mapUpdated) |
salco | 28:ac5c6350ed9a | 153 | { |
salco | 28:ac5c6350ed9a | 154 | return updateMap(mapUpdated,m_posX,m_posY); |
salco | 28:ac5c6350ed9a | 155 | } |
salco | 28:ac5c6350ed9a | 156 | bool Labyrinthe::updateMap(string mapUpdated,char x, char y) |
salco | 28:ac5c6350ed9a | 157 | { |
salco | 28:ac5c6350ed9a | 158 | bool result = true; |
salco | 28:ac5c6350ed9a | 159 | int stringPosition = searchCoord(x,y); |
salco | 28:ac5c6350ed9a | 160 | |
salco | 28:ac5c6350ed9a | 161 | if(stringPosition == -1) |
salco | 28:ac5c6350ed9a | 162 | result= false; |
salco | 28:ac5c6350ed9a | 163 | else { |
salco | 28:ac5c6350ed9a | 164 | mapDuLabyrinthe[(stringPosition)+1] = ((mapDuLabyrinthe[(stringPosition)+1]) & 0xFC) | ((mapUpdated[0] &0x03)<<0); |
salco | 28:ac5c6350ed9a | 165 | mapDuLabyrinthe[(stringPosition)+2] = ((mapDuLabyrinthe[(stringPosition)+2]) & 0x3F) | ((mapUpdated[1] &0x03)<<6); |
salco | 28:ac5c6350ed9a | 166 | mapDuLabyrinthe[(stringPosition)+2] = ((mapDuLabyrinthe[(stringPosition)+2]) & 0xCF) | ((mapUpdated[2] &0x03)<<4); |
salco | 28:ac5c6350ed9a | 167 | |
salco | 28:ac5c6350ed9a | 168 | mapDuLabyrinthe[(stringPosition)+2] = ((mapDuLabyrinthe[(stringPosition)+2]) & 0xF3) | ((mapUpdated[3] &0x03)<<2); |
salco | 28:ac5c6350ed9a | 169 | mapDuLabyrinthe[(stringPosition)+2] = ((mapDuLabyrinthe[(stringPosition)+2]) & 0xFC) | ((mapUpdated[4] &0x03)<<0); |
salco | 28:ac5c6350ed9a | 170 | mapDuLabyrinthe[(stringPosition)+2] = ((mapDuLabyrinthe[(stringPosition)+3]) & 0x3F) | ((mapUpdated[5] &0x03)<<6); |
salco | 28:ac5c6350ed9a | 171 | |
salco | 28:ac5c6350ed9a | 172 | mapDuLabyrinthe[(stringPosition)+2] = ((mapDuLabyrinthe[(stringPosition)+2]) & 0xCF) | ((mapUpdated[6] &0x03)<<4); |
salco | 28:ac5c6350ed9a | 173 | mapDuLabyrinthe[(stringPosition)+2] = ((mapDuLabyrinthe[(stringPosition)+2]) & 0xF3) | ((mapUpdated[7] &0x03)<<2); |
salco | 28:ac5c6350ed9a | 174 | mapDuLabyrinthe[(stringPosition)+2] = ((mapDuLabyrinthe[(stringPosition)+2]) & 0xFC) | ((mapUpdated[8] &0x03)<<0); |
salco | 28:ac5c6350ed9a | 175 | } |
salco | 28:ac5c6350ed9a | 176 | |
salco | 28:ac5c6350ed9a | 177 | |
salco | 28:ac5c6350ed9a | 178 | return result; |
salco | 28:ac5c6350ed9a | 179 | } |
salco | 28:ac5c6350ed9a | 180 | bool Labyrinthe::addMap(char x, char y) |
salco | 28:ac5c6350ed9a | 181 | { |
salco | 28:ac5c6350ed9a | 182 | bool result = true; |
salco | 28:ac5c6350ed9a | 183 | x &= 0x7F; // on coupe le 8eme bit |
salco | 35:d81f6b927932 | 184 | y &= 0x7F; // |
salco | 28:ac5c6350ed9a | 185 | |
salco | 35:d81f6b927932 | 186 | mapDuLabyrinthe.append(1,((x<<1) | (y>>6)) );//x7,x6,x5,x4,x3,x2,x1,y7 |
salco | 35:d81f6b927932 | 187 | mapDuLabyrinthe.append(1,y<<1); //y6,y5,y4,y3,y2,y1,[C1],[C1] |
salco | 35:d81f6b927932 | 188 | mapDuLabyrinthe.append(2,0); //add C2-C9 vide |
salco | 35:d81f6b927932 | 189 | |
salco | 35:d81f6b927932 | 190 | #ifdef DEBUG_LABYRINTHE_ADD_MAP |
salco | 35:d81f6b927932 | 191 | debug("----addMap----\n\r"); |
salco | 35:d81f6b927932 | 192 | debug("x = %i \n\r",x); |
salco | 35:d81f6b927932 | 193 | debug("y = %i \n\r",y); |
salco | 35:d81f6b927932 | 194 | debug("((x<<1) | (y>>6)) = %i \n\r",((x<<1) | (y>>6))); |
salco | 35:d81f6b927932 | 195 | debug("-------------\n\r"); |
salco | 35:d81f6b927932 | 196 | #endif |
salco | 28:ac5c6350ed9a | 197 | |
salco | 28:ac5c6350ed9a | 198 | return result; |
salco | 28:ac5c6350ed9a | 199 | } |
salco | 28:ac5c6350ed9a | 200 | |
salco | 28:ac5c6350ed9a | 201 | int Labyrinthe::searchCoord(char posX,char posY) |
salco | 28:ac5c6350ed9a | 202 | { |
salco | 28:ac5c6350ed9a | 203 | bool result=false; |
salco | 28:ac5c6350ed9a | 204 | //string theMap; |
salco | 28:ac5c6350ed9a | 205 | //theMap.clear(); |
salco | 35:d81f6b927932 | 206 | debug(DEBUGLABSEARCHCOORD,"------Search coord------"); |
salco | 35:d81f6b927932 | 207 | debug(DEBUGLABSEARCHCOORD," posX: %i posY: %i \n\r",posX,posY); |
salco | 35:d81f6b927932 | 208 | |
salco | 28:ac5c6350ed9a | 209 | char newPosX = posX; |
salco | 28:ac5c6350ed9a | 210 | char newPosY = posY; |
salco | 28:ac5c6350ed9a | 211 | |
salco | 28:ac5c6350ed9a | 212 | getCoordoner(newPosX,newPosY); |
salco | 35:d81f6b927932 | 213 | debug(DEBUGLABSEARCHCOORD," new posX: %i new posY: %i \n\r",newPosX,newPosY); |
salco | 28:ac5c6350ed9a | 214 | unsigned char templateX,templateY; |
salco | 28:ac5c6350ed9a | 215 | int i=0; |
salco | 35:d81f6b927932 | 216 | debug(DEBUGLABSEARCHCOORD," map size: %i \n\r",mapDuLabyrinthe.size()); |
salco | 35:d81f6b927932 | 217 | for( ; ((i*DEFAULTLABLEIGHT) < mapDuLabyrinthe.size()) && (!result); i++) { |
salco | 35:d81f6b927932 | 218 | |
salco | 28:ac5c6350ed9a | 219 | templateX = (mapDuLabyrinthe[(i*DEFAULTLABLEIGHT)])>>1; |
salco | 28:ac5c6350ed9a | 220 | templateY = ((mapDuLabyrinthe[(i*DEFAULTLABLEIGHT)])&1)<<7; |
salco | 28:ac5c6350ed9a | 221 | templateY += ((mapDuLabyrinthe[(i*DEFAULTLABLEIGHT)+1])>>2); |
salco | 28:ac5c6350ed9a | 222 | |
salco | 28:ac5c6350ed9a | 223 | if((templateX == newPosX) && (templateY == newPosY)) { |
salco | 28:ac5c6350ed9a | 224 | result=true; |
salco | 28:ac5c6350ed9a | 225 | //theMap.append(1,((mapDuLabyrinthe[(i*DEFAULTLABLEIGHT)+1])& 3)); |
salco | 28:ac5c6350ed9a | 226 | } |
salco | 28:ac5c6350ed9a | 227 | } |
salco | 35:d81f6b927932 | 228 | debug(DEBUGLABSEARCHCOORD," templateX: %i \n\r",templateX); |
salco | 35:d81f6b927932 | 229 | debug(DEBUGLABSEARCHCOORD," templateY: %i \n\r",templateY); |
salco | 35:d81f6b927932 | 230 | debug(DEBUGLABSEARCHCOORD,"--------------------"); |
salco | 28:ac5c6350ed9a | 231 | return (i==0? -1:i*DEFAULTLABLEIGHT); |
salco | 28:ac5c6350ed9a | 232 | } |
salco | 28:ac5c6350ed9a | 233 | |
salco | 28:ac5c6350ed9a | 234 | char Labyrinthe::getC(char cX) |
salco | 28:ac5c6350ed9a | 235 | { |
salco | 28:ac5c6350ed9a | 236 | return getC(m_posX, m_posY, cX); |
salco | 28:ac5c6350ed9a | 237 | } |
salco | 28:ac5c6350ed9a | 238 | char Labyrinthe::getC(char x, char y) |
salco | 28:ac5c6350ed9a | 239 | { |
salco | 28:ac5c6350ed9a | 240 | char newPosX = x; |
salco | 28:ac5c6350ed9a | 241 | char newPosY = y; |
salco | 28:ac5c6350ed9a | 242 | char maCoordoner; |
salco | 28:ac5c6350ed9a | 243 | maCoordoner=getCoordoner(newPosX,newPosY); |
salco | 28:ac5c6350ed9a | 244 | |
salco | 28:ac5c6350ed9a | 245 | return getC(x, y, maCoordoner); |
salco | 28:ac5c6350ed9a | 246 | } |
salco | 28:ac5c6350ed9a | 247 | char Labyrinthe::getC(char x, char y, char cX) |
salco | 28:ac5c6350ed9a | 248 | { |
salco | 28:ac5c6350ed9a | 249 | char myCoordoner = 0xFF; |
salco | 28:ac5c6350ed9a | 250 | string result = showMap(x,y); |
salco | 28:ac5c6350ed9a | 251 | if(result.size() != 0) { |
salco | 28:ac5c6350ed9a | 252 | myCoordoner= result[cX]; |
salco | 28:ac5c6350ed9a | 253 | } |
salco | 28:ac5c6350ed9a | 254 | return myCoordoner; |
salco | 28:ac5c6350ed9a | 255 | } |
salco | 28:ac5c6350ed9a | 256 | void Labyrinthe::setC(char value, char x, char y, char cX) |
salco | 28:ac5c6350ed9a | 257 | { |
salco | 28:ac5c6350ed9a | 258 | string result = showMap(x,y); |
salco | 28:ac5c6350ed9a | 259 | if(result.size() != 0) { |
salco | 28:ac5c6350ed9a | 260 | result[cX]=value; |
salco | 28:ac5c6350ed9a | 261 | updateMap(result,x,y); |
salco | 28:ac5c6350ed9a | 262 | } |
salco | 28:ac5c6350ed9a | 263 | } |
salco | 28:ac5c6350ed9a | 264 | void Labyrinthe::setC(char value, char cX) |
salco | 28:ac5c6350ed9a | 265 | { |
salco | 28:ac5c6350ed9a | 266 | setC(value,m_posX, m_posY,cX); |
salco | 28:ac5c6350ed9a | 267 | } |
salco | 28:ac5c6350ed9a | 268 | void Labyrinthe::setC(char value, char x, char y) |
salco | 28:ac5c6350ed9a | 269 | { |
salco | 28:ac5c6350ed9a | 270 | char newPosX = x; |
salco | 28:ac5c6350ed9a | 271 | char newPosY = y; |
salco | 28:ac5c6350ed9a | 272 | char maCoordoner; |
salco | 28:ac5c6350ed9a | 273 | maCoordoner=getCoordoner(newPosX,newPosY); |
salco | 28:ac5c6350ed9a | 274 | |
salco | 28:ac5c6350ed9a | 275 | setC(value,x,y,maCoordoner); |
salco | 28:ac5c6350ed9a | 276 | } |
salco | 28:ac5c6350ed9a | 277 | void Labyrinthe::setC_Up(char value) |
salco | 28:ac5c6350ed9a | 278 | { |
salco | 28:ac5c6350ed9a | 279 | setC(value,m_posX, m_posY+1); |
salco | 28:ac5c6350ed9a | 280 | } |
salco | 28:ac5c6350ed9a | 281 | void Labyrinthe::setC_Down(char value) |
salco | 28:ac5c6350ed9a | 282 | { |
salco | 28:ac5c6350ed9a | 283 | setC(value,m_posX, m_posY-1); |
salco | 28:ac5c6350ed9a | 284 | } |
salco | 28:ac5c6350ed9a | 285 | void Labyrinthe::setC_Left(char value) |
salco | 28:ac5c6350ed9a | 286 | { |
salco | 28:ac5c6350ed9a | 287 | setC(value,m_posX-1, m_posY); |
salco | 28:ac5c6350ed9a | 288 | } |
salco | 28:ac5c6350ed9a | 289 | void Labyrinthe::setC_Right(char value) |
salco | 28:ac5c6350ed9a | 290 | { |
salco | 28:ac5c6350ed9a | 291 | setC(value,m_posX+1, m_posY); |
salco | 35:d81f6b927932 | 292 | } |
salco | 35:d81f6b927932 | 293 | void Labyrinthe::setMyPos(char value) |
salco | 35:d81f6b927932 | 294 | { |
salco | 35:d81f6b927932 | 295 | setC(value, m_posX, m_posY); |
salco | 28:ac5c6350ed9a | 296 | } |