Changeset 11945 for code/branches/3DPacman_FS18/src/modules
- Timestamp:
- May 5, 2018, 12:12:36 AM (7 years ago)
- Location:
- code/branches/3DPacman_FS18/src/modules/pacman
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/3DPacman_FS18/src/modules/pacman/Pacman.cc
r11944 r11945 70 70 if(timer<=0){ 71 71 afraid = false; 72 t imer = 0;72 this->setNormal(); 73 73 } 74 74 } … … 88 88 89 89 bcolli = false; 90 for(int nrghost = 0; (nrghost< 3) && (!bcolli); ++nrghost){90 for(int nrghost = 0; (nrghost<8) && (!bcolli); ++nrghost){ 91 91 bcolli = collis(ghosts[nrghost]->getPosition(), currentPosition); 92 92 //orxout() << "GHOST" << nrghost << ghosts[nrghost]->getPosition() << endl; … … 127 127 } 128 128 else{ 129 for(int nrghost = 0; nrghost< 3; ++nrghost){129 for(int nrghost = 0; nrghost<8; ++nrghost){ 130 130 bcolli = collis(ghosts[nrghost]->getPosition(), currentPosition); 131 131 if(bcolli) ghosts[nrghost]->resetGhost(); … … 136 136 137 137 void Pacman::setAfraid(){ 138 afraid = true; 138 139 139 timer = 10; //Set timer to 10 seconds 140 141 //Change normal Ghosts with afraid ones 142 if(!afraid){ 143 ghosts[0]->changewith(ghosts[4]); 144 ghosts[1]->changewith(ghosts[5]); 145 ghosts[2]->changewith(ghosts[6]); 146 ghosts[3]->changewith(ghosts[7]); 147 } 148 149 afraid = true; 150 } 151 152 void Pacman::setNormal(){ 153 154 timer = 0; 155 156 //Change normal Ghosts with afraid ones 157 if(afraid){ 158 ghosts[4]->changewith(ghosts[0]); 159 ghosts[5]->changewith(ghosts[1]); 160 ghosts[6]->changewith(ghosts[2]); 161 ghosts[7]->changewith(ghosts[3]); 162 } 163 164 afraid = false; 140 165 } 141 166 -
code/branches/3DPacman_FS18/src/modules/pacman/Pacman.h
r11944 r11945 81 81 int getPoints(); 82 82 void setAfraid(); 83 void setNormal(); 83 84 84 85 -
code/branches/3DPacman_FS18/src/modules/pacman/PacmanGhost.cc
r11944 r11945 51 51 52 52 this->actuelposition = this->getPosition(); 53 54 if(findpos(actuelposition, Vector3(0,-20,0))) 55 dontmove = true; 53 56 54 57 this->target_x = actuelposition.x; … … 414 417 } 415 418 419 void changewith(PacmanGhost* otherghost){ 420 otherghost->setPosition(this->getPosition()); 421 this->setPosition(0,-20,0); 422 otherghost->target_x = this->target_x; //Probleme bei parallelen Porzessen 423 otherghost->target_y = this->target_y; 424 otherghost->ismoving = this->ismoving; 425 426 this->dontmove = true; 427 otherghost->dontmove = false; 428 } 416 429 417 430 … … 422 435 423 436 bool PacmanGhost::findpos(Vector3 one, Vector3 other){ 424 if((abs(one.x - other.x)<0.5) && (abs(one. z - other.z)<0.5)) return true;437 if((abs(one.x - other.x)<0.5) && (abs(one.y - other.y)<0.5) && (abs(one.z - other.z)<0.5)) return true; 425 438 return false; 426 439 } -
code/branches/3DPacman_FS18/src/modules/pacman/PacmanGhost.h
r11940 r11945 55 55 void setnewTarget(int firstdec, int seconddec, int thirddec); 56 56 void setnewTarget(int firstdec, int seconddec, int thirddec, int fourthdec); 57 57 void changewith(PacmanGhost* otherghost); 58 58 59 59 bool findpos(Vector3 one, Vector3 other); 60 60 void changemovability(); 61 61 bool dontmove = false; 62 private: 62 63 Vector3 actuelposition; 63 64 bool ismoving = false; 64 int decision = 0; //Gives the random which way information to the ghost.65 65 int target_x = 0; 66 66 int target_z = 0; 67 Vector3 actuelposition; 67 68 private: 69 int decision = 0; //Gives the random which way information to the ghost. 68 70 Vector3 velocity; 69 71 Vector3 resetposition = Vector3(0,10,15);
Note: See TracChangeset
for help on using the changeset viewer.