- Timestamp:
- May 24, 2018, 3:36:40 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/3DPacman_FS18/src/modules/pacman/PacmanGhost.cc
r11979 r11992 21 21 * 22 22 * Author: 23 * Oli Scheuss23 * Marc Dreher 24 24 * Co-authors: 25 * Damian 'Mozork' Frick25 * .. 26 26 * 27 27 */ … … 62 62 /** 63 63 @brief 64 Destructor. Destroys controller, if present.64 Destructor. Destroys ghost, if present. 65 65 */ 66 66 PacmanGhost::~PacmanGhost() … … 71 71 /** 72 72 @brief 73 Method for creating a AutonomousDronethrough XML.73 Method for creating a ghost through XML. 74 74 */ 75 75 void PacmanGhost::XMLPort(Element& xmlelement, XMLPort::Mode mode) … … 79 79 80 80 81 81 //All positions in the map, see documentation 82 82 Vector3 possibleposition[] = {Vector3(20,10,245),Vector3(215,10,245),Vector3(215,10,195),Vector3(185,10,195),Vector3(135,10,195), //0-4 83 83 Vector3(185,10,150),Vector3(135,10,150),Vector3(215,10,150),Vector3(215,10,105),Vector3(135,10,105), //5-9 … … 97 97 /** 98 98 @brief 99 Defines which actions the AutonomousDronehas to take in each tick.99 Defines which actions the ghost has to take in each tick. 100 100 @param dt 101 101 The length of the tick. … … 104 104 { 105 105 SUPER(PacmanGhost, tick, dt); 106 107 //setorientation108 106 109 107 this->actuelposition = this->getPosition(); … … 340 338 } 341 339 340 //Random choice of new target (not used in game, but useful) 342 341 void PacmanGhost::setnewTarget(int firstdec){ 343 342 … … 352 351 } 353 352 353 //Random choice of new target 354 354 void PacmanGhost::setnewTarget(int firstdec, int seconddec){ 355 355 decision = rand()%2; … … 369 369 } 370 370 371 //Random choice of new target 371 372 void PacmanGhost::setnewTarget(int firstdec, int seconddec, int thirddec){ 372 373 … … 392 393 } 393 394 395 //Random choice of new target 394 396 void PacmanGhost::setnewTarget(int firstdec, int seconddec, int thirddec, int fourthdec){ 395 397 … … 420 422 } 421 423 424 //Change this with other ghost 422 425 void PacmanGhost::changewith(PacmanGhost* otherghost){ 423 426 424 427 while(lockmove){}; 425 lockmove = true; 428 lockmove = true; //Prevent change of target while ghost is changed 426 429 427 430 otherghost->setPosition(this->getPosition()); 428 431 this->setPosition(0,-20,0); 429 otherghost->target_x = this->target_x; //Probleme bei parallelen Porzessen432 otherghost->target_x = this->target_x; 430 433 otherghost->target_z = this->target_z; 431 434 otherghost->ismoving = this->ismoving; … … 437 440 } 438 441 439 442 //Move ghost with rotation 440 443 void PacmanGhost::move(float dt, Vector3 actuelposition, Vector3 velocity){ 441 444 if(!dontmove){ 442 445 this->setPosition(Vector3(actuelposition.x+speed*velocity.x*dt,10,actuelposition.z+speed*velocity.z*dt)); 446 447 //Rotate ghost in the direction of movement 443 448 if((abs(abs(velocity.x)-1)<0.1) && (abs(velocity.z-0)<0.1)) 444 449 if(velocity.x<0){ … … 455 460 this->setOrientation(Quaternion(Radian(0), Vector3(0, 1, 0))); 456 461 } 457 this->getOrientation();458 462 459 463 } 460 464 } 461 465 466 //Check if there is a collision 462 467 bool PacmanGhost::findpos(Vector3 one, Vector3 other){ 463 468 if((abs(one.x - other.x)<0.5) && (abs(one.y - other.y)<0.5) && (abs(one.z - other.z)<0.5)) return true; … … 465 470 } 466 471 472 //Change ability to move 467 473 void PacmanGhost::changemovability(){ 468 474 if(dontmove){ … … 473 479 } 474 480 481 //ResetGhost 475 482 void PacmanGhost::resetGhost(){ 476 483 … … 484 491 } 485 492 493 //Increase speed of ghosts 486 494 void PacmanGhost::levelupvelo(){ 487 495 speed ++;
Note: See TracChangeset
for help on using the changeset viewer.