Changeset 12322 for code/branches/3DPacman_FS19/src/modules/pacman
- Timestamp:
- Apr 24, 2019, 10:38:07 PM (6 years ago)
- Location:
- code/branches/3DPacman_FS19/src/modules/pacman
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/3DPacman_FS19/src/modules/pacman/PacmanBrown.cc
r12320 r12322 13 13 14 14 RegisterObject(PacmanBrown); 15 16 this->target_x=0; 17 this->target_z=15; 18 this->lastPlayerPassedPoint=Vector3(0,0,0); //Vector3(70,10,-135); 15 19 16 20 } … … 29 33 30 34 31 Ogre::Vector3 diffVector;35 Vector3 diffVector; 32 36 diffVector.x=pos2.x-pos1.x; 33 37 diffVector.y=pos2.y-pos1.y; //should always be 0 … … 43 47 44 48 this->actuelposition = this->getPosition(); 49 50 51 for(int u=0; u < 67; u++){//always check if player passed a point 52 if(jeanfindpos(this->getPlayerPos(), possibleposition[u])){ 53 this->lastPlayerPassedPoint=possibleposition[u]; 54 } 55 } 56 45 57 46 58 //Stop, if target arrived … … 60 72 } 61 73 } 74 else if(this->lastPlayerPassedPoint==Vector3(0,0,0)){ 75 //as long as the player has not started the game, 76 //i.e. lastPlayerPastPoint is (0,0,0), brown pacman 77 //cannot possibly move, because it needs the position 78 //of the player to move accordingly 79 80 this->ismoving=false; 81 std::cout<<"weie"<<endl; 82 } 62 83 63 84 //Check on which position the ghost has arrived and set new target 64 85 else{ 65 86 std::cout<<"naye"<<endl; 66 87 while(lockmove){}; 67 88 lockmove = true; … … 83 104 } 84 105 85 else if((this->isFleeing==true)&&( brownPos!=Vector3(-215,10,-195))){106 else if((this->isFleeing==true)&&(!findpos(brownPos,Vector3(-215,10,-195)))){ 86 107 //if fleeing, continue to flee 87 108 Vector3 nextMove = getShortestPath(brownPos, Vector3(-215, 10, -195)); 88 109 setNewTargetGhost(nextMove); 89 110 } 90 else if ((this->isFleeing==true)&&( brownPos==Vector3(-215,10,-195))){111 else if ((this->isFleeing==true)&&(findpos(brownPos,Vector3(-215,10,-195)))){ 91 112 //if fleeing and reached flee point, go back near player 92 113 this->isFleeing=false; … … 98 119 Vector3 nextMove = getShortestPath(brownPos, this->lastPlayerPassedPoint); 99 120 setNewTargetGhost(nextMove); 121 } 122 if(this->isFleeing){ 123 std::cout<<"fleeing"<<endl; 100 124 } 101 125 } … … 131 155 132 156 } 157 158 159 160 bool PacmanBrown::isAdjacentToPlayerLastPastPoint(Vector3 pacmanBrownPos, Vector3 arrayForNeighborPositions[]){ 161 //return true if brownPacman is on an adjacent position to the last 162 //point visited by the player. return false otherwise. 163 164 for(int i =0; i < 4; i++){ 165 if(arrayForNeighborPositions[i]!=Vector3(0,0,0)){ 166 if(findpos(pacmanBrownPos, arrayForNeighborPositions[i])){ 167 return true; 168 } 169 } 170 } 171 return false; 172 } 173 174 175 176 void PacmanBrown::findNeighboorPositions(Vector3 actuelposition, Vector3 adjacentPositions[], Vector3 positionArray[]){ 177 //this function should put in adjacentPosition[] the neighboors of lastPlayerPastPoint 178 179 if(findpos(actuelposition,possibleposition[0])){ 180 181 182 adjacentPositions[0]=positionArray[1]; //graphVertex(possibleposition[1]); //need to do it everywhere !!! 183 adjacentPositions[1]=positionArray[17]; //graphVertex(possibleposition[17]); 184 adjacentPositions[2]=positionArray[19]; //graphVertex(possibleposition[19]); //maybe a vector would be more suitable ? 185 } 186 else if(findpos(actuelposition,possibleposition[1])){ 187 adjacentPositions[0]=positionArray[0]; //graphVertex(possibleposition[0]); 188 adjacentPositions[1]=positionArray[2]; //graphVertex(possibleposition[2]); 189 } 190 else if(findpos(actuelposition,possibleposition[2])){ 191 adjacentPositions[0]=positionArray[1]; //graphVertex(possibleposition[1]); 192 adjacentPositions[1]=positionArray[3]; //graphVertex(possibleposition[3]); 193 } 194 else if(findpos(actuelposition,possibleposition[3])){ 195 adjacentPositions[0]=positionArray[2]; //graphVertex(possibleposition[2]); 196 adjacentPositions[1]=positionArray[4]; //graphVertex(possibleposition[4]); 197 adjacentPositions[2]=positionArray[5]; //graphVertex(possibleposition[5]); 198 } 199 else if(findpos(actuelposition,possibleposition[4])){ 200 adjacentPositions[0]=positionArray[3]; //graphVertex(possibleposition[3]); 201 adjacentPositions[1]=positionArray[6]; //graphVertex(possibleposition[6]); 202 } 203 else if(findpos(actuelposition,possibleposition[5])){ 204 adjacentPositions[0]=positionArray[3]; //graphVertex(possibleposition[3]); 205 adjacentPositions[1]=positionArray[7]; //graphVertex(possibleposition[7]); 206 } 207 else if(findpos(actuelposition,possibleposition[6])){ 208 adjacentPositions[0]=positionArray[4]; //graphVertex(possibleposition[4]); 209 adjacentPositions[1]=positionArray[9]; //graphVertex(possibleposition[9]); 210 adjacentPositions[2]=positionArray[26]; //graphVertex(possibleposition[26]); 211 } 212 else if(findpos(actuelposition,possibleposition[7])){ 213 adjacentPositions[0]=positionArray[5]; //graphVertex(possibleposition[5]); 214 adjacentPositions[1]=positionArray[8]; //graphVertex(possibleposition[8]); 215 } 216 else if(findpos(actuelposition,possibleposition[8])){ 217 adjacentPositions[0]=positionArray[7]; //graphVertex(possibleposition[7]); 218 adjacentPositions[1]=positionArray[9]; //graphVertex(possibleposition[9]); 219 } 220 else if(findpos(actuelposition,possibleposition[9])){ 221 adjacentPositions[0]=positionArray[6]; //graphVertex(possibleposition[6]); 222 adjacentPositions[1]=positionArray[8]; //graphVertex(possibleposition[8]); 223 adjacentPositions[2]=positionArray[10]; //graphVertex(possibleposition[10]); 224 adjacentPositions[3]=positionArray[38]; //graphVertex(possibleposition[38]); 225 } 226 else if(findpos(actuelposition,possibleposition[10])){ 227 adjacentPositions[0]=positionArray[9]; //graphVertex(possibleposition[9]); 228 adjacentPositions[1]=positionArray[11]; //graphVertex(possibleposition[11]); 229 adjacentPositions[2]=positionArray[45]; //graphVertex(possibleposition[45]); 230 } 231 else if(findpos(actuelposition,possibleposition[11])){ 232 adjacentPositions[0]=positionArray[10]; //graphVertex(possibleposition[10]); 233 adjacentPositions[1]=positionArray[12]; //graphVertex(possibleposition[12]); 234 adjacentPositions[2]=positionArray[13]; //graphVertex(possibleposition[13]); 235 } 236 else if(findpos(actuelposition,possibleposition[12])){ 237 adjacentPositions[0]=positionArray[11]; //graphVertex(possibleposition[11]); 238 adjacentPositions[1]=positionArray[14]; //graphVertex(possibleposition[14]); 239 } 240 else if(findpos(actuelposition,possibleposition[13])){ 241 adjacentPositions[0]=positionArray[11]; //graphVertex(possibleposition[11]); 242 adjacentPositions[1]=positionArray[14]; //graphVertex(possibleposition[14]); 243 adjacentPositions[2]=positionArray[16]; //graphVertex(possibleposition[16]); 244 adjacentPositions[3]=positionArray[61]; //graphVertex(possibleposition[61]); 245 } 246 else if(findpos(actuelposition,possibleposition[14])){ 247 adjacentPositions[0]=positionArray[12]; //graphVertex(possibleposition[12]); 248 adjacentPositions[1]=positionArray[13]; //graphVertex(possibleposition[13]); 249 adjacentPositions[2]=positionArray[15]; //graphVertex(possibleposition[15]); 250 } 251 else if(findpos(actuelposition,possibleposition[15])){ 252 adjacentPositions[0]=positionArray[14]; //graphVertex(possibleposition[14]); 253 adjacentPositions[1]=positionArray[16]; //graphVertex(possibleposition[16]); 254 } 255 else if(findpos(actuelposition,possibleposition[16])){ 256 adjacentPositions[0]=positionArray[13]; //graphVertex(possibleposition[13]); 257 adjacentPositions[1]=positionArray[15]; //graphVertex(possibleposition[15]); 258 adjacentPositions[2]=positionArray[62]; //graphVertex(possibleposition[62]); 259 } 260 else if(findpos(actuelposition,possibleposition[17])){ 261 adjacentPositions[0]=positionArray[0]; //graphVertex(possibleposition[0]); 262 adjacentPositions[1]=positionArray[25]; //graphVertex(possibleposition[25]); 263 } 264 else if(findpos(actuelposition,possibleposition[18])){ 265 adjacentPositions[0]=positionArray[19]; //graphVertex(possibleposition[19]); 266 adjacentPositions[1]=positionArray[24]; //graphVertex(possibleposition[24]); 267 } 268 else if(findpos(actuelposition,possibleposition[19])){ 269 adjacentPositions[0]=positionArray[0]; //graphVertex(possibleposition[0]); 270 adjacentPositions[1]=positionArray[18]; //graphVertex(possibleposition[18]); 271 adjacentPositions[2]=positionArray[20]; //graphVertex(possibleposition[20]); 272 } 273 else if(findpos(actuelposition,possibleposition[20])){ 274 adjacentPositions[0]=positionArray[19]; //graphVertex(possibleposition[19]); 275 adjacentPositions[1]=positionArray[21]; //graphVertex(possibleposition[21]); 276 } 277 else if(findpos(actuelposition,possibleposition[21])){ 278 adjacentPositions[0]=positionArray[20]; //graphVertex(possibleposition[20]); 279 adjacentPositions[1]=positionArray[22]; //graphVertex(possibleposition[22]); 280 } 281 else if(findpos(actuelposition,possibleposition[22])){ 282 adjacentPositions[0]=positionArray[21]; //graphVertex(possibleposition[21]); 283 adjacentPositions[1]=positionArray[23]; //graphVertex(possibleposition[23]); 284 adjacentPositions[2]=positionArray[31]; //graphVertex(possibleposition[31]); 285 } 286 else if(findpos(actuelposition,possibleposition[23])){ 287 adjacentPositions[0]=positionArray[22]; //graphVertex(possibleposition[22]); 288 adjacentPositions[1]=positionArray[30]; //graphVertex(possibleposition[30]); 289 } 290 else if(findpos(actuelposition,possibleposition[24])){ 291 adjacentPositions[0]=positionArray[18]; //graphVertex(possibleposition[18]); 292 adjacentPositions[1]=positionArray[29]; //graphVertex(possibleposition[29]); 293 } 294 else if(findpos(actuelposition,possibleposition[25])){ 295 adjacentPositions[0]=positionArray[17]; //graphVertex(possibleposition[17]); 296 adjacentPositions[1]=positionArray[26]; //graphVertex(possibleposition[26]); 297 } 298 else if(findpos(actuelposition,possibleposition[26])){ 299 adjacentPositions[0]=positionArray[6]; //graphVertex(possibleposition[6]); 300 adjacentPositions[1]=positionArray[25]; //graphVertex(possibleposition[25]); 301 adjacentPositions[2]=positionArray[27]; //graphVertex(possibleposition[27]); 302 } 303 else if(findpos(actuelposition,possibleposition[27])){ 304 adjacentPositions[0]=positionArray[26]; //graphVertex(possibleposition[26]); 305 adjacentPositions[1]=positionArray[28]; //graphVertex(possibleposition[28]); 306 adjacentPositions[2]=positionArray[37]; //graphVertex(possibleposition[37]); 307 } 308 else if(findpos(actuelposition,possibleposition[28])){ 309 adjacentPositions[0]=positionArray[27]; //graphVertex(possibleposition[27]); 310 adjacentPositions[1]=positionArray[29]; //graphVertex(possibleposition[29]); 311 adjacentPositions[2]=positionArray[36]; //graphVertex(possibleposition[36]); 312 } 313 else if(findpos(actuelposition,possibleposition[29])){ 314 adjacentPositions[0]=positionArray[24]; //graphVertex(possibleposition[24]); 315 adjacentPositions[1]=positionArray[28]; //graphVertex(possibleposition[28]); 316 adjacentPositions[2]=positionArray[30]; //graphVertex(possibleposition[30]); 317 } 318 else if(findpos(actuelposition,possibleposition[30])){ 319 adjacentPositions[0]=positionArray[23]; //graphVertex(possibleposition[23]); 320 adjacentPositions[1]=positionArray[29]; //graphVertex(possibleposition[29]); 321 adjacentPositions[2]=positionArray[34]; //graphVertex(possibleposition[34]); 322 } 323 else if(findpos(actuelposition,possibleposition[31])){ 324 adjacentPositions[0]=positionArray[22]; //graphVertex(possibleposition[22]); 325 adjacentPositions[1]=positionArray[32]; //graphVertex(possibleposition[32]); 326 } 327 else if(findpos(actuelposition,possibleposition[32])){ 328 adjacentPositions[0]=positionArray[31]; //graphVertex(possibleposition[31]); 329 adjacentPositions[1]=positionArray[33]; //graphVertex(possibleposition[33]); 330 } 331 else if(findpos(actuelposition,possibleposition[33])){ 332 adjacentPositions[0]=positionArray[32]; //graphVertex(possibleposition[32]); 333 adjacentPositions[1]=positionArray[34]; //graphVertex(possibleposition[34]); 334 } 335 else if(findpos(actuelposition,possibleposition[34])){ 336 adjacentPositions[0]=positionArray[30]; //graphVertex(possibleposition[30]); 337 adjacentPositions[1]=positionArray[33]; //graphVertex(possibleposition[33]); 338 adjacentPositions[2]=positionArray[35]; //graphVertex(possibleposition[35]); 339 adjacentPositions[3]=positionArray[42]; //graphVertex(possibleposition[42]); 340 341 } 342 else if(findpos(actuelposition,possibleposition[35])){ 343 adjacentPositions[0]=positionArray[34]; //graphVertex(possibleposition[34]); 344 adjacentPositions[1]=positionArray[36]; //graphVertex(possibleposition[36]); 345 adjacentPositions[2]=positionArray[41]; //graphVertex(possibleposition[41]); 346 } 347 else if(findpos(actuelposition,possibleposition[36])){ 348 adjacentPositions[0]=positionArray[28]; //graphVertex(possibleposition[28]); 349 adjacentPositions[1]=positionArray[35]; //graphVertex(possibleposition[35]); 350 } 351 else if(findpos(actuelposition,possibleposition[37])){ 352 adjacentPositions[0]=positionArray[27]; //graphVertex(possibleposition[27]); 353 adjacentPositions[1]=positionArray[38]; //graphVertex(possibleposition[38]); 354 } 355 else if(findpos(actuelposition,possibleposition[38])){ 356 adjacentPositions[0]=positionArray[9]; //graphVertex(possibleposition[9]); 357 adjacentPositions[1]=positionArray[37]; //graphVertex(possibleposition[37]); 358 adjacentPositions[2]=positionArray[39]; //graphVertex(possibleposition[39]); 359 } 360 else if(findpos(actuelposition,possibleposition[39])){ 361 adjacentPositions[0]=positionArray[38]; //graphVertex(possibleposition[38]); 362 adjacentPositions[1]=positionArray[40]; //graphVertex(possibleposition[40]); 363 adjacentPositions[2]=positionArray[45]; //graphVertex(possibleposition[45]); 364 } 365 else if(findpos(actuelposition,possibleposition[40])){ 366 adjacentPositions[0]=positionArray[39]; //graphVertex(possibleposition[39]); 367 adjacentPositions[1]=positionArray[41]; //graphVertex(possibleposition[41]); 368 } 369 else if(findpos(actuelposition,possibleposition[41])){ 370 adjacentPositions[0]=positionArray[35]; //graphVertex(possibleposition[35]); 371 adjacentPositions[1]=positionArray[43]; //graphVertex(possibleposition[43]); 372 } 373 else if(findpos(actuelposition,possibleposition[42])){ 374 adjacentPositions[0]=positionArray[34]; //graphVertex(possibleposition[34]); 375 adjacentPositions[1]=positionArray[43]; //graphVertex(possibleposition[43]); 376 adjacentPositions[2]=positionArray[54]; //graphVertex(possibleposition[54]); 377 } 378 else if(findpos(actuelposition,possibleposition[43])){ 379 adjacentPositions[0]=positionArray[41]; //graphVertex(possibleposition[41]); 380 adjacentPositions[1]=positionArray[46]; //graphVertex(possibleposition[46]); 381 } 382 else if(findpos(actuelposition,possibleposition[44])){ 383 adjacentPositions[0]=positionArray[40]; //graphVertex(possibleposition[40]); 384 adjacentPositions[1]=positionArray[66]; //graphVertex(possibleposition[66]); 385 } 386 else if(findpos(actuelposition,possibleposition[45])){ 387 adjacentPositions[0]=positionArray[10]; //graphVertex(possibleposition[10]); 388 adjacentPositions[1]=positionArray[39]; //graphVertex(possibleposition[39]); 389 adjacentPositions[2]=positionArray[49]; //graphVertex(possibleposition[49]); 390 } 391 else if(findpos(actuelposition,possibleposition[46])){ 392 adjacentPositions[0]=positionArray[43]; //graphVertex(possibleposition[43]); 393 adjacentPositions[1]=positionArray[47]; //graphVertex(possibleposition[47]); 394 } 395 else if(findpos(actuelposition,possibleposition[47])){ 396 adjacentPositions[0]=positionArray[46]; //graphVertex(possibleposition[46]); 397 adjacentPositions[1]=positionArray[52]; //graphVertex(possibleposition[52]); 398 adjacentPositions[2]=positionArray[66]; //graphVertex(possibleposition[66]); 399 } 400 else if(findpos(actuelposition,possibleposition[48])){ 401 adjacentPositions[0]=positionArray[49]; //graphVertex(possibleposition[49]); 402 adjacentPositions[1]=positionArray[51]; //graphVertex(possibleposition[51]); 403 adjacentPositions[2]=positionArray[66]; //graphVertex(possibleposition[66]); 404 } 405 else if(findpos(actuelposition,possibleposition[49])){ 406 adjacentPositions[0]=positionArray[45]; //graphVertex(possibleposition[45]); 407 adjacentPositions[1]=positionArray[48]; //graphVertex(possibleposition[48]); 408 } 409 else if(findpos(actuelposition,possibleposition[50])){ 410 adjacentPositions[0]=positionArray[51]; //graphVertex(possibleposition[51]); 411 adjacentPositions[1]=positionArray[61]; //graphVertex(possibleposition[61]); 412 } 413 else if(findpos(actuelposition,possibleposition[51])){ 414 adjacentPositions[0]=positionArray[48]; //graphVertex(possibleposition[48]); 415 adjacentPositions[1]=positionArray[50]; //graphVertex(possibleposition[50]); 416 } 417 else if(findpos(actuelposition,possibleposition[52])){ 418 adjacentPositions[0]=positionArray[47]; //graphVertex(possibleposition[47]); 419 adjacentPositions[1]=positionArray[53]; //graphVertex(possibleposition[53]); 420 } 421 else if(findpos(actuelposition,possibleposition[53])){ 422 adjacentPositions[0]=positionArray[52]; //graphVertex(possibleposition[52]); 423 adjacentPositions[1]=positionArray[58]; //graphVertex(possibleposition[58]); 424 } 425 else if(findpos(actuelposition,possibleposition[54])){ 426 adjacentPositions[0]=positionArray[42]; //graphVertex(possibleposition[42]); 427 adjacentPositions[1]=positionArray[55]; //graphVertex(possibleposition[55]); 428 adjacentPositions[2]=positionArray[57]; //graphVertex(possibleposition[57]); 429 } 430 else if(findpos(actuelposition,possibleposition[55])){ 431 adjacentPositions[0]=positionArray[54]; //graphVertex(possibleposition[54]); 432 adjacentPositions[1]=positionArray[56]; //graphVertex(possibleposition[56]); 433 } 434 else if(findpos(actuelposition,possibleposition[56])){ 435 adjacentPositions[0]=positionArray[55]; //graphVertex(possibleposition[55]); 436 adjacentPositions[1]=positionArray[57]; //graphVertex(possibleposition[57]); 437 adjacentPositions[2]=positionArray[65]; //graphVertex(possibleposition[65]); 438 } 439 else if(findpos(actuelposition,possibleposition[57])){ 440 adjacentPositions[0]=positionArray[54]; //graphVertex(possibleposition[54]); 441 adjacentPositions[1]=positionArray[56]; //graphVertex(possibleposition[56]); 442 adjacentPositions[2]=positionArray[58]; //graphVertex(possibleposition[58]); 443 adjacentPositions[3]=positionArray[64]; //graphVertex(possibleposition[64]); 444 445 } 446 else if(findpos(actuelposition,possibleposition[58])){ 447 adjacentPositions[0]=positionArray[53]; //graphVertex(possibleposition[53]); 448 adjacentPositions[1]=positionArray[57]; //graphVertex(possibleposition[57]); 449 adjacentPositions[2]=positionArray[59]; //graphVertex(possibleposition[59]); 450 } 451 else if(findpos(actuelposition,possibleposition[59])){ 452 adjacentPositions[0]=positionArray[58]; //graphVertex(possibleposition[58]); 453 adjacentPositions[1]=positionArray[59]; //graphVertex(possibleposition[59]); 454 adjacentPositions[2]=positionArray[63]; //graphVertex(possibleposition[63]); 455 } 456 else if(findpos(actuelposition,possibleposition[60])){ 457 adjacentPositions[0]=positionArray[59]; //graphVertex(possibleposition[59]); 458 adjacentPositions[1]=positionArray[61]; //graphVertex(possibleposition[61]); 459 adjacentPositions[2]=positionArray[62]; //graphVertex(possibleposition[62]); 460 } 461 else if(findpos(actuelposition,possibleposition[61])){ 462 adjacentPositions[0]=positionArray[13]; //graphVertex(possibleposition[13]); 463 adjacentPositions[1]=positionArray[50]; //graphVertex(possibleposition[50]); 464 adjacentPositions[2]=positionArray[60]; //graphVertex(possibleposition[60]); 465 } 466 else if(findpos(actuelposition,possibleposition[62])){ 467 adjacentPositions[0]=positionArray[16]; //graphVertex(possibleposition[16]); 468 adjacentPositions[1]=positionArray[60]; //graphVertex(possibleposition[60]); 469 } 470 else if(findpos(actuelposition,possibleposition[63])){ 471 adjacentPositions[0]=positionArray[59]; //graphVertex(possibleposition[59]); 472 adjacentPositions[1]=positionArray[64]; //graphVertex(possibleposition[64]); 473 } 474 else if(findpos(actuelposition,possibleposition[64])){ 475 adjacentPositions[0]=positionArray[57]; //graphVertex(possibleposition[57]); 476 adjacentPositions[1]=positionArray[63]; //graphVertex(possibleposition[63]); 477 adjacentPositions[2]=positionArray[65]; //graphVertex(possibleposition[65]); 478 } 479 else if(findpos(actuelposition,possibleposition[65])){ 480 adjacentPositions[0]=positionArray[56]; //graphVertex(possibleposition[56]); 481 adjacentPositions[1]=positionArray[64]; //graphVertex(possibleposition[64]); 482 } 483 else if(findpos(actuelposition,possibleposition[66])){ 484 adjacentPositions[0]=positionArray[47]; //graphVertex(possibleposition[47]); 485 adjacentPositions[1]=positionArray[48]; //graphVertex(possibleposition[48]); 486 } 133 487 } 134 488 135 489 136 490 137 138 139 140 141 491 } 142 492 143 493 -
code/branches/3DPacman_FS19/src/modules/pacman/PacmanBrown.h
r12320 r12322 35 35 bool isFleeing; 36 36 37 bool isAdjacentToPlayerLastPastPoint(Vector3 pacmanBrownPos, Vector3 arrayForNeighborPositions[]); 38 39 void findNeighboorPositions(Vector3 actuelposition, Vector3 adjacentPositions[], Vector3 positionArray[]); 40 37 41 38 42 }; -
code/branches/3DPacman_FS19/src/modules/pacman/PacmanCyan.cc
r12321 r12322 16 16 this->target_x=0; 17 17 this->target_z=15; 18 this->setPosition(Vector3(0,10,15)); 18 19 this->lastPlayerPassedPoint=Vector3(70,10,-135); 19 20 … … 66 67 else{ 67 68 69 std::cout<<startPatrol<<endl; 70 std::cout<<goalPatrol<<endl; 71 std::cout<<isPatrolling<<endl; 72 std::cout<<this->actuelposition<<endl; 73 std::cout<<this->passedByStart<<endl; 74 std::cout<<this->passedByGoal<<endl; 75 68 76 while(lockmove){}; 69 77 lockmove = true; … … 78 86 79 87 } 80 else if((this->isPatrolling==true)&&(cyanPos!=this->goalPatrol)){ 88 else if/*((!findpos(cyanPos, startPatrol))&&*/(this->passedByStart==false)/*)*/{ 89 //we have not even reached our startPatrol point 81 90 91 if(findpos(cyanPos, startPatrol)){ 92 this->passedByStart=true; 93 } 94 else{ 95 nextMove(cyanPos, startPatrol); 96 } 97 } 98 else if/*((!findpos(cyanPos, goalPatrol))&&*/(this->passedByGoal==false)/*)*/{ 99 //we have reached our startPatrol point, now we go to goalPoint 82 100 101 if(findpos(cyanPos, goalPatrol)){ 102 this->passedByGoal=true; 103 } 104 else{ 105 nextMove(cyanPos, goalPatrol); 106 } 83 107 84 108 } 85 else if(cyanPos==this->goalPatrol){ 109 else if(!findpos(cyanPos, this->startPatrol)){ 110 //we reached our goal, now we return to start 111 112 nextMove(cyanPos, startPatrol); 86 113 87 114 } 88 else if(cyanPos==this->startPatrol){ 115 else /*if(findpos(cyanPos, this->startPatrol))*/{ 116 //we reached startPoint again. Either we change patrol 117 //or redo same patrol 89 118 119 int redoORNot = rand()%2; 120 121 if(redoORNot==1){ 122 123 this->isPatrolling=false; 124 //we will change patrol region 125 } 126 else { 127 this->passedByGoal=false; 128 //repeat patrol region 129 } 90 130 } 91 131 92 132 93 94 133 95 134 … … 102 141 103 142 104 int indexRand1=rand()%67;143 int indexRand1=rand()%67; 105 144 while(indexRand1==44){ 106 145 //new try if index is that of the position in the middle … … 122 161 this->goalPatrol = possibleposition[indexRand2]; 123 162 124 Vector3 nextMovement = getShortestPath(startPatrol, goalPatrol); 163 /*PatrolPosition startPatPol = PatrolPosition(startPatrol); 164 PatrolPosition goalPatrol = PatrolPosition(goalPatrol);*/ 165 166 this->passedByStart=false; 167 this->passedByGoal=false; 168 this->isPatrolling=true; 125 169 126 170 } … … 130 174 131 175 void PacmanCyan::nextMove( Vector3 cyanPosP, Vector3 playerPos){ 132 133 Vector3 nextTarget;134 176 135 nextTarget = getShortestPath(cyanPosP, playerPos);177 Vector3 nextTarget = getShortestPath(cyanPosP, playerPos); 136 178 137 179 setNewTargetGhost(nextTarget); 138 180 } 139 181 140 struct PacmanCyan::PatrolPosition{182 /*struct PacmanCyan::PatrolPosition{ 141 183 //we need to check if PacmanCyan already passed the goal resp. start patrol point 142 184 … … 151 193 } 152 194 153 }; 195 };*/ 154 196 155 197 -
code/branches/3DPacman_FS19/src/modules/pacman/PacmanCyan.h
r12321 r12322 29 29 struct PatrolPosition; 30 30 31 bool passedByStart; 32 bool passedByGoal; 33 31 34 32 35 -
code/branches/3DPacman_FS19/src/modules/pacman/PacmanGhost.cc
r12319 r12322 1311 1311 1312 1312 if(indexForSWNE==4){ 1313 std::cout<<"Ryukyu"<<endl;1313 //std::cout<<"Ryukyu"<<endl; 1314 1314 return pacLasVisPos; 1315 1315 } -
code/branches/3DPacman_FS19/src/modules/pacman/PacmanPink.cc
r12319 r12322 16 16 this->target_x=0; 17 17 this->target_z=15; 18 this->lastPlayerPassedPoint=Vector3( 70,10,-135);18 this->lastPlayerPassedPoint=Vector3(0,0,0); //Vector3(70,10,-135); 19 19 20 20 } … … 60 60 } 61 61 } 62 else if(this->lastPlayerPassedPoint==Vector3(0,0,0)){ 63 //as long as the player has not started the game, 64 //i.e. lastPlayerPastPoint is (0,0,0), pink pacman 65 //cannot possibly move, because it needs the position 66 //of the player to move accordingly 67 68 this->ismoving=false; 69 } 62 70 //Check on which position the ghost has arrived and set new target 63 71 else{ … … 67 75 Vector3 pinkPos=Vector3(this->target_x, 10, this->target_z); 68 76 77 std::cout<<this->lastPlayerPassedPoint<<endl; 78 69 79 int directionV = findPlayerTravDir (lastPlayerPassedPoint, this->getPlayerPos()); 70 80 this->pointInFrontOfPlayer=getPointInFrontOfPacman(lastPlayerPassedPoint, directionV); 71 81 72 82 std::cout<<this->pointInFrontOfPlayer<<endl; 73 83 nextMove(pinkPos, pointInFrontOfPlayer, lastPlayerPassedPoint); 74 84 -
code/branches/3DPacman_FS19/src/modules/pacman/PacmanRed.cc
r12319 r12322 16 16 this->target_x=0; 17 17 this->target_z=15; 18 this->lastPlayerPassedPoint=Vector3( 70,10,-135);18 this->lastPlayerPassedPoint=Vector3(0,0,0); //Vector3(70,10,-135); 19 19 this->isNearPlayer=false; 20 20 … … 81 81 } 82 82 //std::cout<<"LemanExpress4"<<endl; 83 } 84 else if(this->lastPlayerPassedPoint==Vector3(0,0,0)){ 85 //as long as the player has not started the game, 86 //i.e. lastPlayerPastPoint is (0,0,0), red pacman 87 //cannot possibly move, because it needs the position 88 //of the player to move accordingly 89 90 this->ismoving=false; 83 91 } 84 92
Note: See TracChangeset
for help on using the changeset viewer.