Changeset 12408 for code/branches/Presentation_FS19
- Timestamp:
- May 22, 2019, 1:58:40 PM (6 years ago)
- Location:
- code/branches/Presentation_FS19
- Files:
-
- 8 edited
- 12 copied
Legend:
- Unmodified
- Added
- Removed
-
code/branches/Presentation_FS19
- Property svn:mergeinfo changed
/code/branches/3DPacman_FS19 (added) merged: 12206,12252,12259,12272,12293,12303-12304,12313,12316-12326,12338,12357,12365,12375,12380-12381,12383,12385-12386,12389
- Property svn:mergeinfo changed
-
code/branches/Presentation_FS19/data/levels/3DPacman.oxw
r12045 r12408 35 35 36 36 <!-- GHOSTS --> 37 <Pacman Ghost position="0,10,15">37 <PacmanRed position="0,10,15" colour='1'> 38 38 <attached> 39 39 <Model position="0,0,0" mesh="PacmanGhostRed.mesh" scale="5" /> 40 40 </attached> 41 </PacmanRed> 42 43 <PacmanCyan position="0,10,15" colour='2'> 44 <attached> 45 <Model position="0,0,0" mesh="PacmanGhostBlue.mesh" scale="5" /> 46 </attached> 47 </PacmanCyan> 48 49 <PacmanBrown position="0,10,15" colour='3'> 50 <attached> 51 <Model position="0,0,0" mesh="PacmanGhostOrange.mesh" scale="5" /> 52 </attached> 53 </PacmanBrown> 54 55 <PacmanPink position="0,10,15" colour='4'> 56 <attached> 57 <Model position="0,0,0" mesh="PacmanGhostPink.mesh" scale="5" /> 58 </attached> 59 </PacmanPink> 60 61 62 <PacmanGhost position="0,-20,0" > 63 <attached> 64 <Model position="0,0,0" mesh="PacmanAfraidGhost.mesh" scale="5" /> 65 </attached> 41 66 </PacmanGhost> 42 67 43 <PacmanGhost position="0, 10,15" >44 <attached> 45 <Model position="0,0,0" mesh="Pacman GhostBlue.mesh" scale="5" />68 <PacmanGhost position="0,-20,0" > 69 <attached> 70 <Model position="0,0,0" mesh="PacmanAfraidGhost.mesh" scale="5" /> 46 71 </attached> 47 72 </PacmanGhost> 48 73 49 <PacmanGhost position="0, 10,15" >50 <attached> 51 <Model position="0,0,0" mesh="Pacman GhostOrange.mesh" scale="5" />74 <PacmanGhost position="0,-20,0" > 75 <attached> 76 <Model position="0,0,0" mesh="PacmanAfraidGhost.mesh" scale="5" /> 52 77 </attached> 53 78 </PacmanGhost> 54 79 55 <PacmanGhost position="0, 10,15" >56 <attached> 57 <Model position="0,0,0" mesh="Pacman GhostPink.mesh" scale="5" />80 <PacmanGhost position="0,-20,0" > 81 <attached> 82 <Model position="0,0,0" mesh="PacmanAfraidGhost.mesh" scale="5" /> 58 83 </attached> 59 84 </PacmanGhost> 60 85 61 86 62 <PacmanGhost position="0,-20,0" >63 <attached>64 <Model position="0,0,0" mesh="PacmanAfraidGhost.mesh" scale="5" />65 </attached>66 </PacmanGhost>67 68 <PacmanGhost position="0,-20,0" >69 <attached>70 <Model position="0,0,0" mesh="PacmanAfraidGhost.mesh" scale="5" />71 </attached>72 </PacmanGhost>73 74 <PacmanGhost position="0,-20,0" >75 <attached>76 <Model position="0,0,0" mesh="PacmanAfraidGhost.mesh" scale="5" />77 </attached>78 </PacmanGhost>79 80 <PacmanGhost position="0,-20,0" >81 <attached>82 <Model position="0,0,0" mesh="PacmanAfraidGhost.mesh" scale="5" />83 </attached>84 </PacmanGhost>85 86 87 87 88 88 <!-- POINTS first Line --> 89 90 <PacmanLaser position="20,-20000,150"> 91 <attached> 92 <Model position="0, 0, 0" yaw="90" pitch="-90" roll="0" scale3D="5, 5, 50" mesh="LaserBeam2.mesh" /> 93 </attached> 94 </PacmanLaser> 95 89 96 <PacmanPointSphere position="-215,10,245"> 90 97 <attached> -
code/branches/Presentation_FS19/src/modules/pacman/CMakeLists.txt
r12290 r12408 6 6 PacmanPointAfraid.cc 7 7 PacmanHUDinfo.cc 8 PacmanRandom.cc 9 PacmanRed.cc 10 PacmanPink.cc 11 PacmanBrown.cc 12 PacmanCyan.cc 13 PacmanLaser.cpp 8 14 ) 9 15 -
code/branches/Presentation_FS19/src/modules/pacman/Pacman.cc
r12003 r12408 39 39 RegisterClass(Pacman); 40 40 41 int PACMAN_INTERNAL_PACMAN_POSITION; 42 41 43 Pacman::Pacman(Context* context) : Deathmatch(context) 42 44 { … … 46 48 point = 0; 47 49 level = 1; 50 laser = 5; //after that number of eaten pointSpheres, the laser appears 48 51 49 52 } … … 56 59 } 57 60 61 62 PacmanLaser* pos = *(ObjectList<PacmanLaser>().begin()); 63 pos->resetPacmanLaser(); 64 65 66 58 67 for(PacmanPointAfraid* next : ObjectList<PacmanPointAfraid>()){ 59 68 next->resetPacmanPointAfraid(); … … 73 82 74 83 75 PacmanGhost* ghosts[ 4];84 PacmanGhost* ghosts[8]; 76 85 77 86 78 87 void Pacman::tick(float dt) 79 88 { 89 80 90 SUPER(Pacman, tick, dt); 91 81 92 82 93 //Needed for gameover 83 94 if(deathtime != 0){ 84 95 dead(dt); 96 97 98 85 99 } 86 100 … … 88 102 else{ 89 103 104 //support by laser 105 if(point > laser + 240*(level-1)){ 106 107 for(PacmanPointSphere* pointer : ObjectList<PacmanPointSphere>()){ 108 Vector3 pointSpherePosition = pointer->getPosition(); 109 110 if(pointSpherePosition.y > 0){// pointSphere above surface =not eaten yet 111 112 PacmanLaser* pos = *(ObjectList<PacmanLaser>().begin()); 113 pos->setPosition(pointSpherePosition); 114 break; 115 } 116 117 118 } 119 120 } 121 90 122 //Register ghosts 91 123 int i = 0; 92 for(PacmanGhost* nextghost 124 for(PacmanGhost* nextghost: ObjectList<PacmanGhost>()){ 93 125 ghosts[i] = nextghost; 94 126 i++; 95 127 } 96 97 128 //Switch ghost to not-catchable, if timer is zero 98 129 if(afraid){ … … 137 168 //Check for collisions between to objects (compare float numbers) 138 169 bool Pacman::collis(Vector3 one, Vector3 other){ 139 if((abs(one.x-other.x)<1 0) && (abs(one.y-other.y)<10) && (abs(one.z-other.z)<10))170 if((abs(one.x-other.x)<19) && (abs(one.y-other.y)<10) && (abs(one.z-other.z)<19)) 140 171 return true; 141 172 return false; … … 203 234 void Pacman::takePoint(PacmanPointSphere* taken){ 204 235 ++point; 236 205 237 if(point == totallevelpoint){ 206 238 this->levelUp(); -
code/branches/Presentation_FS19/src/modules/pacman/Pacman.h
r11992 r12408 40 40 #include "PacmanPointSphere.h" 41 41 #include "PacmanPointAfraid.h" 42 42 #include "PacmanLaser.h" 43 43 44 44 #include "core/EventIncludes.h" … … 60 60 namespace orxonox 61 61 { 62 /* 63 deklaration ohne Speicher zu reservieren. definition in Pacman.cc 64 wird benoetigt um auf die Position global zuzugreifen 65 66 analog pacman_next 67 68 */ 69 extern int PACMAN_INTERNAL_PACMAN_POSITION; 62 70 63 71 class _PacmanExport Pacman : public Deathmatch … … 106 114 int point; 107 115 int lives; 116 int laser; 108 117 109 118 }; -
code/branches/Presentation_FS19/src/modules/pacman/PacmanGhost.cc
r12009 r12408 32 32 #include "BulletDynamics/Dynamics/btRigidBody.h" 33 33 34 #include <vector> 35 34 36 namespace orxonox 35 37 { 36 RegisterClass(PacmanGhost); 37 38 /** 39 @brief 40 Constructor. Registers the object and initializes some default values. 41 @param creator 42 The creator of this object. 43 */ 44 PacmanGhost::PacmanGhost(Context* context) : ControllableEntity(context) 45 { 46 RegisterObject(PacmanGhost); 47 48 this->velocity = Vector3(0, 0, 0); 49 50 this->setCollisionType(CollisionType::Dynamic); 51 52 this->actuelposition = this->getPosition(); 53 54 if(findpos(actuelposition, Vector3(0,-20,0))) 55 dontmove = true; 56 57 this->target_x = actuelposition.x; 58 this->target_z = actuelposition.z; 59 60 } 61 62 /** 63 @brief 64 Destructor. Destroys ghost, if present. 65 */ 66 PacmanGhost::~PacmanGhost() 67 { 68 // Deletes the controller if the object was initialized and the pointer to the controller is not NULL. 69 } 70 71 /** 72 @brief 73 Method for creating a ghost through XML. 74 */ 75 void PacmanGhost::XMLPort(Element& xmlelement, XMLPort::Mode mode) 76 { 77 SUPER(PacmanGhost, XMLPort, xmlelement, mode); 78 } 79 80 81 //All positions in the map, see documentation 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 Vector3(185,10,150),Vector3(135,10,150),Vector3(215,10,150),Vector3(215,10,105),Vector3(135,10,105), //5-9 84 Vector3(135,10,15),Vector3(135,10,-85),Vector3(215,10,-85),Vector3(135,10,-135),Vector3(215,10,-135), //10-14 85 Vector3(215,10,-195),Vector3(135,10,-195),Vector3(20,10,195),Vector3(-20,10,195),Vector3(-20,10,245), //15-19 86 Vector3(-215,10,245),Vector3(-215,10,195),Vector3(-185,10,195),Vector3(-135,10,195),Vector3(-70,10,195), //20-24 87 Vector3(70,10,195),Vector3(70,10,150),Vector3(20,10,150),Vector3(-20,10,150),Vector3(-70,10,150), //25-29 88 Vector3(-135,10,150),Vector3(-185,10,150),Vector3(-215,10,150),Vector3(-215,10,105),Vector3(-135,10,105), //30-34 89 Vector3(-70,10,105),Vector3(-20,10,105),Vector3(20,10,105),Vector3(70,10,105),Vector3(70,10,60), //35-39 90 Vector3(0,10,60),Vector3(-70,10,60),Vector3(-135,10,15),Vector3(-70,10,60),Vector3(0,10,15), //40-44 91 Vector3(70,10,15),Vector3(-70,10,-35),Vector3(-20,10,-35),Vector3(20,10,-35),Vector3(70,10,-35), //45-49 92 Vector3(70,10,-85),Vector3(20,10,-85),Vector3(-20,10,-85),Vector3(-70,10,-85),Vector3(-135,10,-85), //50-54 93 Vector3(-215,10,-85),Vector3(-215,10,-135),Vector3(-135,10,-135),Vector3(-70,10,-135),Vector3(-20,10,-135), //55-59 94 Vector3(20,10,-135),Vector3(70,10,-135),Vector3(20,10,-195),Vector3(-20,10,-195),Vector3(-135,10,-195), //60-64 95 Vector3(-215,10,-195),Vector3(0,10,-35)}; //65-66 96 97 /** 98 @brief 99 Defines which actions the ghost has to take in each tick. 100 @param dt 101 The length of the tick. 102 */ 103 void PacmanGhost::tick(float dt) 104 { 105 SUPER(PacmanGhost, tick, dt); 106 107 this->actuelposition = this->getPosition(); 108 109 //Stop, if target arrived 110 if((abs(this->actuelposition.x - this->target_x)<0.5) && (abs(this->actuelposition.z - this->target_z)<0.5)){ 111 this->ismoving = false; 112 } 113 114 //Move, if ghost hasn't arrived yet 115 if(this->ismoving){ 116 if(!(abs(this->actuelposition.z-target_z)<0.5)) { 117 velocity = Vector3(0,0,-sgn(this->actuelposition.z-this->target_z)); 118 move(dt, actuelposition, velocity); 119 } 120 if(!(abs(this->actuelposition.x-target_x)<0.5)){ 121 velocity = Vector3(-sgn(this->actuelposition.x-this->target_x),0,0); 122 move(dt, actuelposition, velocity); 123 } 124 } 125 //Check on which position the ghost has arrived and set new target 126 else{ 127 while(lockmove){}; 128 lockmove = true; 129 130 if(findpos(actuelposition,possibleposition[0])){ 131 setnewTarget(1,17,19); 132 } 133 else if(findpos(actuelposition,possibleposition[1])){ 134 setnewTarget(0,2); 135 } 136 else if(findpos(actuelposition,possibleposition[2])){ 137 setnewTarget(1,3); 138 } 139 else if(findpos(actuelposition,possibleposition[3])){ 140 setnewTarget(2,4,5); 141 } 142 else if(findpos(actuelposition,possibleposition[4])){ 143 setnewTarget(3,6); 144 } 145 else if(findpos(actuelposition,possibleposition[5])){ 146 setnewTarget(3,7); 147 } 148 else if(findpos(actuelposition,possibleposition[6])){ 149 setnewTarget(4,9,26); 150 } 151 else if(findpos(actuelposition,possibleposition[7])){ 152 setnewTarget(5,8); 153 } 154 else if(findpos(actuelposition,possibleposition[8])){ 155 setnewTarget(7,9); 156 } 157 else if(findpos(actuelposition,possibleposition[9])){ 158 setnewTarget(6,8,10,38); 159 } 160 else if(findpos(actuelposition,possibleposition[10])){ 161 setnewTarget(9,11,45); 162 } 163 else if(findpos(actuelposition,possibleposition[11])){ 164 setnewTarget(10,12,13); 165 } 166 else if(findpos(actuelposition,possibleposition[12])){ 167 setnewTarget(11,14); 168 } 169 else if(findpos(actuelposition,possibleposition[13])){ 170 setnewTarget(11,14,16,61); 171 } 172 else if(findpos(actuelposition,possibleposition[14])){ 173 setnewTarget(12,13,15); 174 } 175 else if(findpos(actuelposition,possibleposition[15])){ 176 setnewTarget(14,16); 177 } 178 else if(findpos(actuelposition,possibleposition[16])){ 179 setnewTarget(13,15,62); 180 } 181 else if(findpos(actuelposition,possibleposition[17])){ 182 setnewTarget(0,25); 183 } 184 else if(findpos(actuelposition,possibleposition[18])){ 185 setnewTarget(19,24); 186 } 187 else if(findpos(actuelposition,possibleposition[19])){ 188 setnewTarget(0,18,20); 189 } 190 else if(findpos(actuelposition,possibleposition[20])){ 191 setnewTarget(19,21); 192 } 193 else if(findpos(actuelposition,possibleposition[21])){ 194 setnewTarget(20,22); 195 } 196 else if(findpos(actuelposition,possibleposition[22])){ 197 setnewTarget(21,23,31); 198 } 199 else if(findpos(actuelposition,possibleposition[23])){ 200 setnewTarget(22,30); 201 } 202 else if(findpos(actuelposition,possibleposition[24])){ 203 setnewTarget(18,29); 204 } 205 else if(findpos(actuelposition,possibleposition[25])){ 206 setnewTarget(17,26); 207 } 208 else if(findpos(actuelposition,possibleposition[26])){ 209 setnewTarget(6,25,27); 210 } 211 else if(findpos(actuelposition,possibleposition[27])){ 212 setnewTarget(26,28,37); 213 } 214 else if(findpos(actuelposition,possibleposition[28])){ 215 setnewTarget(27,29,36); 216 } 217 else if(findpos(actuelposition,possibleposition[29])){ 218 setnewTarget(24,28,30); 219 } 220 else if(findpos(actuelposition,possibleposition[30])){ 221 setnewTarget(23,29,34); 222 } 223 else if(findpos(actuelposition,possibleposition[31])){ 224 setnewTarget(22,32); 225 } 226 else if(findpos(actuelposition,possibleposition[32])){ 227 setnewTarget(31,33); 228 } 229 else if(findpos(actuelposition,possibleposition[33])){ 230 setnewTarget(32,34); 231 } 232 else if(findpos(actuelposition,possibleposition[34])){ 233 setnewTarget(30,33,35,42); 234 } 235 else if(findpos(actuelposition,possibleposition[35])){ 236 setnewTarget(34,36,41); 237 } 238 else if(findpos(actuelposition,possibleposition[36])){ 239 setnewTarget(28,35); 240 } 241 else if(findpos(actuelposition,possibleposition[37])){ 242 setnewTarget(27,38); 243 } 244 else if(findpos(actuelposition,possibleposition[38])){ 245 setnewTarget(9,37,39); 246 } 247 else if(findpos(actuelposition,possibleposition[39])){ 248 setnewTarget(38,40,45); 249 } 250 else if(findpos(actuelposition,possibleposition[40])){ 251 setnewTarget(39,41); //Shouldn't be able to return in center 252 } 253 else if(findpos(actuelposition,possibleposition[41])){ 254 setnewTarget(35,43); 255 } 256 else if(findpos(actuelposition,possibleposition[42])){ 257 setnewTarget(34,43,54); 258 } 259 else if(findpos(actuelposition,possibleposition[43])){ 260 setnewTarget(41,46); 261 } 262 else if(findpos(actuelposition,possibleposition[44])){ 263 setnewTarget(40,66); 264 } 265 else if(findpos(actuelposition,possibleposition[45])){ 266 setnewTarget(10,39,49); 267 } 268 else if(findpos(actuelposition,possibleposition[46])){ 269 setnewTarget(43,47); 270 } 271 else if(findpos(actuelposition,possibleposition[47])){ 272 setnewTarget(46,52,66); 273 } 274 else if(findpos(actuelposition,possibleposition[48])){ 275 setnewTarget(49,51,66); 276 } 277 else if(findpos(actuelposition,possibleposition[49])){ 278 setnewTarget(45,48); 279 } 280 else if(findpos(actuelposition,possibleposition[50])){ 281 setnewTarget(51,61); 282 } 283 else if(findpos(actuelposition,possibleposition[51])){ 284 setnewTarget(48,50); 285 } 286 else if(findpos(actuelposition,possibleposition[52])){ 287 setnewTarget(47,53); 288 } 289 else if(findpos(actuelposition,possibleposition[53])){ 290 setnewTarget(52,58); 291 } 292 else if(findpos(actuelposition,possibleposition[54])){ 293 setnewTarget(42,55,57); 294 } 295 else if(findpos(actuelposition,possibleposition[55])){ 296 setnewTarget(54,56); 297 } 298 else if(findpos(actuelposition,possibleposition[56])){ 299 setnewTarget(55,57,65); 300 } 301 else if(findpos(actuelposition,possibleposition[57])){ 302 setnewTarget(54,56,58,64); 303 } 304 else if(findpos(actuelposition,possibleposition[58])){ 305 setnewTarget(53,57,59); 306 } 307 else if(findpos(actuelposition,possibleposition[59])){ 308 setnewTarget(58,59,63); 309 } 310 else if(findpos(actuelposition,possibleposition[60])){ 311 setnewTarget(59,61,62); 312 } 313 else if(findpos(actuelposition,possibleposition[61])){ 314 setnewTarget(13,50,60); 315 } 316 else if(findpos(actuelposition,possibleposition[62])){ 317 setnewTarget(16,60); 318 } 319 else if(findpos(actuelposition,possibleposition[63])){ 320 setnewTarget(59,64); 321 } 322 else if(findpos(actuelposition,possibleposition[64])){ 323 setnewTarget(57,63,65); 324 } 325 else if(findpos(actuelposition,possibleposition[65])){ 326 setnewTarget(56,64); 327 } 328 else if(findpos(actuelposition,possibleposition[66])){ 329 setnewTarget(47,48); 330 } 331 332 else{ 333 this->resetGhost(); //Shouldn't happen... 334 } //End of Position table 335 lockmove = false; 336 } 337 338 } 339 340 //Random choice of new target (not used in game, but useful) 341 void PacmanGhost::setnewTarget(int firstdec){ 342 343 decision = rand()%1; 344 switch(decision){ 345 case 0: 346 this->target_x = possibleposition[firstdec].x; 347 this->target_z = possibleposition[firstdec].z; 348 this->ismoving = true; 349 break; 350 } 351 } 352 353 //Random choice of new target 354 void PacmanGhost::setnewTarget(int firstdec, int seconddec){ 355 decision = rand()%2; 356 switch(decision){ 357 case 0: 358 this->target_x = possibleposition[firstdec].x; 359 this->target_z = possibleposition[firstdec].z; 360 this->ismoving = true; 361 break; 362 case 1: 363 this->target_x = possibleposition[seconddec].x; 364 this->target_z = possibleposition[seconddec].z; 365 this->ismoving = true; 366 break; 367 } 38 39 40 struct PacmanGhost::graphVertex { 41 42 public: 43 44 Vector3 position; 45 graphVertex *adjacentVertices[4]; //neighbooring vertices 46 47 int shortestDistanceToStart; //actual shortest distance to start point 48 graphVertex* actuelPredecessor; //the predecessor giving the for now shortest 49 //path to start 50 graphVertex* currentNearestNonVisitedNeighboor; 51 bool alreadyVisited; 52 graphVertex(){ //default constructor 53 position=0; 54 shortestDistanceToStart= std::numeric_limits<int>::max(); 55 actuelPredecessor=nullptr; 56 alreadyVisited=false; 57 for(int kl =0; kl <4;kl++){ 58 adjacentVertices[kl]=nullptr; //first put all position in array listing neighboors to 0 59 } 60 } 61 graphVertex(Vector3 wantedPosition){ //normal constructor 62 position=wantedPosition; 63 shortestDistanceToStart= std::numeric_limits<int>::max(); //default distance is infinity 64 actuelPredecessor=nullptr; 65 alreadyVisited=false; 66 for(int kl =0; kl <4;kl++){ 67 adjacentVertices[kl]=nullptr; //first put all position in array listing neighboors to 0 68 } 69 } 70 graphVertex& operator = (const graphVertex &rightSide){ 71 this->position=rightSide.position; 72 this->shortestDistanceToStart=rightSide.shortestDistanceToStart; 73 this->actuelPredecessor=rightSide.actuelPredecessor; 74 this->currentNearestNonVisitedNeighboor=rightSide.currentNearestNonVisitedNeighboor; 75 this->alreadyVisited=rightSide.alreadyVisited; 76 77 return *this; 78 } 79 80 }; 81 82 83 static PacmanGhost::graphVertex listOfVertices[67]; 84 85 //Check if there is a collision 86 bool findpos(Vector3 one, Vector3 other){ 87 if((abs(one.x - other.x)<0.5) && (abs(one.y - other.y)<0.5) && (abs(one.z - other.z)<0.5)) return true; 88 return false; 89 } 90 91 //All positions in the map, see documentation 92 Vector3 possibleposition[67] = {Vector3(20,10,245),Vector3(215,10,245),Vector3(215,10,195),Vector3(185,10,195),Vector3(135,10,195), //0-4 93 Vector3(185,10,150),Vector3(135,10,150),Vector3(215,10,150),Vector3(215,10,105),Vector3(135,10,105), //5-9 94 Vector3(135,10,15),Vector3(135,10,-85),Vector3(215,10,-85),Vector3(135,10,-135),Vector3(215,10,-135), //10-14 95 Vector3(215,10,-195),Vector3(135,10,-195),Vector3(20,10,195),Vector3(-20,10,195),Vector3(-20,10,245), //15-19 96 Vector3(-215,10,245),Vector3(-215,10,195),Vector3(-185,10,195),Vector3(-135,10,195),Vector3(-70,10,195), //20-24 97 Vector3(70,10,195),Vector3(70,10,150),Vector3(20,10,150),Vector3(-20,10,150),Vector3(-70,10,150), //25-29 98 Vector3(-135,10,150),Vector3(-185,10,150),Vector3(-215,10,150),Vector3(-215,10,105),Vector3(-135,10,105), //30-34 99 Vector3(-70,10,105),Vector3(-20,10,105),Vector3(20,10,105),Vector3(70,10,105),Vector3(70,10,60), //35-39 100 Vector3(0,10,60),Vector3(-70,10,60),Vector3(-135,10,15),Vector3(-70,10,60),Vector3(0,10,15), //40-44 101 Vector3(70,10,15),Vector3(-70,10,-35),Vector3(-20,10,-35),Vector3(20,10,-35),Vector3(70,10,-35), //45-49 102 Vector3(70,10,-85),Vector3(20,10,-85),Vector3(-20,10,-85),Vector3(-70,10,-85),Vector3(-135,10,-85), //50-54 103 Vector3(-215,10,-85),Vector3(-215,10,-135),Vector3(-135,10,-135),Vector3(-70,10,-135),Vector3(-20,10,-135), //55-59 104 Vector3(20,10,-135),Vector3(70,10,-135),Vector3(20,10,-195),Vector3(-20,10,-195),Vector3(-135,10,-195), //60-64 105 Vector3(-215,10,-195),Vector3(0,10,-35)}; //65-66 106 107 RegisterClass(PacmanGhost); 108 109 /** 110 @brief 111 Constructor. Registers the object and initializes some default values. 112 @param creator 113 The creator of this object. 114 */ 115 PacmanGhost::PacmanGhost(Context* context) : ControllableEntity(context) 116 { 117 RegisterObject(PacmanGhost); 118 119 this->velocity = Vector3(0, 0, 0); 120 121 this->setCollisionType(CollisionType::Dynamic); 122 123 this->actuelposition = this->getPosition(); 124 125 if(findpos(actuelposition, Vector3(0,-20,0))) 126 dontmove = true; 127 128 this->target_x = actuelposition.x; 129 this->target_z = actuelposition.z; 130 131 } 132 133 /** 134 @brief 135 Destructor. Destroys ghost, if present. 136 */ 137 PacmanGhost::~PacmanGhost() 138 { 139 // Deletes the controller if the object was initialized and the pointer to the controller is not nullptr. 140 } 141 142 /** 143 @brief 144 Method for creating a ghost through XML. 145 */ 146 void PacmanGhost::XMLPort(Element& xmlelement, XMLPort::Mode mode) 147 { 148 SUPER(PacmanGhost, XMLPort, xmlelement, mode); 149 } 150 151 //Change this with other ghost 152 void PacmanGhost::changewith(PacmanGhost* otherghost){ 153 154 while(lockmove){}; 155 lockmove = true; //Prevent change of target while ghost is changed 156 157 otherghost->setPosition(this->getPosition()); 158 this->setPosition(0,-20,0); 159 otherghost->target_x = this->target_x; 160 otherghost->target_z = this->target_z; 161 otherghost->ismoving = this->ismoving; 162 163 this->dontmove = true; 164 otherghost->dontmove = false; 165 166 lockmove = false; 167 } 168 169 //Move ghost with rotation 170 void PacmanGhost::move(float dt, Vector3 actuelposition, Vector3 velocity){ 171 if(!dontmove){ 172 this->setPosition(Vector3(actuelposition.x+speed*velocity.x*dt,10,actuelposition.z+speed*velocity.z*dt)); 173 174 //Rotate ghost in the direction of movement 175 if((abs(abs(velocity.x)-1)<0.1) && (abs(velocity.z-0)<0.1)){ 176 if(velocity.x<0){ 177 this->setOrientation(Quaternion(Radian(-1.57), Vector3(0, 1, 0))); 178 } 179 else{ 180 this->setOrientation(Quaternion(Radian(1.57), Vector3(0, 1, 0))); 181 } 182 } 183 if((abs(abs(velocity.z)-1)<0.1) && (abs(velocity.x-0)<0.1)){ 184 if(velocity.z<0){ 185 this->setOrientation(Quaternion(Radian(3.14), Vector3(0, 1, 0))); 186 } 187 else{ 188 this->setOrientation(Quaternion(Radian(0), Vector3(0, 1, 0))); 189 } 190 } 191 192 } 193 } 194 195 //Change ability to move 196 void PacmanGhost::changemovability(){ 197 if(dontmove){ 198 dontmove = false;} 199 else{ 200 dontmove = true; 201 } 202 } 203 204 //ResetGhost 205 void PacmanGhost::resetGhost(){ 206 207 this->setPosition(this->resetposition); 208 this->ismoving = false; 209 this->actuelposition = this->getPosition(); 210 211 this->target_x = actuelposition.x; 212 this->target_z = actuelposition.z; 213 214 } 215 216 //Increase speed of ghosts 217 void PacmanGhost::levelupvelo(){ 218 speed ++; 219 } 220 221 Vector3 PacmanGhost::getPlayerPos() 222 { 223 for (PacmanGelb* player : ObjectList<PacmanGelb>()) 224 { 225 return player->getWorldPosition(); 226 } 227 228 return Vector3(0,0,0); //default, should not be used 229 230 } 231 232 233 bool PacmanGhost::jeanfindpos(Vector3 one, Vector3 other){ 234 //This function is used to detect the last Vector3 position that the player crossed. 235 236 if((abs(one.x - other.x)<15) && (abs(one.y - other.y)<15) && (abs(one.z - other.z)<15)) return true; 237 return false; 238 } 239 240 void PacmanGhost::setNewTargetGhost(Vector3 goalToGo){ 241 //Ghosts will go to goalToGo 242 243 this->target_x = goalToGo.x; 244 this->target_z = goalToGo.z; 245 this->ismoving = true; 246 } 247 248 249 /// 250 //// getShortestPath ///////// 251 /// 252 253 254 255 Vector3 PacmanGhost::getShortestPath(Vector3 start, Vector3 goal, Vector3 pointToAvoidP1){ 256 //this function should then somehow produce the algorithm and call all other functions 257 //and finally return the best neighboor of the actual position of the pacman 258 259 //(optional parameter) pointToAvoidP1 is a point that cannot be considered 260 261 262 graphVertex listOfVerticesM[67]; //our list of all possible graphs 263 graphVertex* actualVertex; //we will walk through the array with a pointer 264 265 266 if(start==goal){ // basic case 267 return start; 268 } 269 270 for(int an=0; an < 67; an++){ 271 listOfVerticesM[an]= graphVertex(possibleposition[an]); //same position order as in other file 368 272 369 } 370 371 //Random choice of new target 372 void PacmanGhost::setnewTarget(int firstdec, int seconddec, int thirddec){ 373 374 decision = rand()%3; 375 switch(decision){ 376 case 0: 377 this->target_x = possibleposition[firstdec].x; 378 this->target_z = possibleposition[firstdec].z; 379 this->ismoving = true; 380 break; 381 case 1: 382 this->target_x = possibleposition[seconddec].x; 383 this->target_z = possibleposition[seconddec].z; 384 this->ismoving = true; 385 break; 386 case 2: 387 this->target_x = possibleposition[thirddec].x; 388 this->target_z = possibleposition[thirddec].z; 389 this->ismoving = true; 390 break; 391 } 392 393 } 394 395 //Random choice of new target 396 void PacmanGhost::setnewTarget(int firstdec, int seconddec, int thirddec, int fourthdec){ 397 398 decision = rand()%4; 399 switch(decision){ 400 case 0: 401 this->target_x = possibleposition[firstdec].x; 402 this->target_z = possibleposition[firstdec].z; 403 this->ismoving = true; 404 break; 405 case 1: 406 this->target_x = possibleposition[seconddec].x; 407 this->target_z = possibleposition[seconddec].z; 408 this->ismoving = true; 409 break; 410 case 2: 411 this->target_x = possibleposition[thirddec].x; 412 this->target_z = possibleposition[thirddec].z; 413 this->ismoving = true; 414 break; 415 case 3: 416 this->target_x = possibleposition[fourthdec].x; 417 this->target_z = possibleposition[fourthdec].z; 418 this->ismoving = true; 419 break; 420 } 421 422 } 423 424 //Change this with other ghost 425 void PacmanGhost::changewith(PacmanGhost* otherghost){ 426 427 while(lockmove){}; 428 lockmove = true; //Prevent change of target while ghost is changed 429 430 otherghost->setPosition(this->getPosition()); 431 this->setPosition(0,-20,0); 432 otherghost->target_x = this->target_x; 433 otherghost->target_z = this->target_z; 434 otherghost->ismoving = this->ismoving; 435 436 this->dontmove = true; 437 otherghost->dontmove = false; 438 439 lockmove = false; 440 } 441 442 //Move ghost with rotation 443 void PacmanGhost::move(float dt, Vector3 actuelposition, Vector3 velocity){ 444 if(!dontmove){ 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 448 if((abs(abs(velocity.x)-1)<0.1) && (abs(velocity.z-0)<0.1)) 449 if(velocity.x<0){ 450 this->setOrientation(Quaternion(Radian(-1.57), Vector3(0, 1, 0))); 451 } 452 else{ 453 this->setOrientation(Quaternion(Radian(1.57), Vector3(0, 1, 0))); 454 } 455 if((abs(abs(velocity.z)-1)<0.1) && (abs(velocity.x-0)<0.1)) 456 if(velocity.z<0){ 457 this->setOrientation(Quaternion(Radian(3.14), Vector3(0, 1, 0))); 458 } 459 else{ 460 this->setOrientation(Quaternion(Radian(0), Vector3(0, 1, 0))); 461 } 462 463 } 464 } 465 466 //Check if there is a collision 467 bool PacmanGhost::findpos(Vector3 one, Vector3 other){ 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; 469 return false; 470 } 471 472 //Change ability to move 473 void PacmanGhost::changemovability(){ 474 if(dontmove){ 475 dontmove = false;} 476 else{ 477 dontmove = true; 478 } 479 } 480 481 //ResetGhost 482 void PacmanGhost::resetGhost(){ 483 484 this->setPosition(this->resetposition); 485 this->ismoving = false; 486 this->actuelposition = this->getPosition(); 487 488 this->target_x = actuelposition.x; 489 this->target_z = actuelposition.z; 490 491 } 492 493 //Increase speed of ghosts 494 void PacmanGhost::levelupvelo(){ 495 speed ++; 496 } 273 274 if(start==possibleposition[an]){ 275 actualVertex= &listOfVerticesM[an]; //our pointer points to the graph with position start in array 276 277 } 278 } 279 280 actualVertex->alreadyVisited=true; //our start point is now visited 281 actualVertex->shortestDistanceToStart=0; //At our start point, distance from start is 0 282 findNeighboorVertices(actualVertex->position, actualVertex->adjacentVertices, listOfVerticesM); 283 // second parameter is an array ! //third is our global array 284 285 while(actualVertex->position!=goal){ 286 for(int h=0;h < 4; h++){ 287 if(actualVertex->adjacentVertices[h]!=nullptr){ //check all neighboors of our current graphVertex 288 289 290 updateShortestDistanceToStart(*actualVertex, *actualVertex->adjacentVertices[h]); 291 } //we "update" the neighboors of our new visited vertex 292 293 } 294 295 actualVertex=findNextVertexToConsider(listOfVerticesM, pointToAvoidP1); 296 actualVertex->alreadyVisited=true; 297 298 if(actualVertex->position!=goal){ 299 findNeighboorVertices(actualVertex->position, actualVertex->adjacentVertices, listOfVerticesM); 300 //we find the neighboors of our new visited vertex 301 } 302 } 303 304 //we should have reached our goal at this point 305 306 while(actualVertex->actuelPredecessor->actuelPredecessor!=nullptr){ //the predecessor of our predecessor 307 actualVertex=actualVertex->actuelPredecessor; 308 } 309 // the predecessor is our starting point, in other words we are now on an 310 //adjacent vertex of the start 311 312 return actualVertex->position; //we return the position of this - adjacent to start - vertex 313 } 314 315 //end of getShortestPath 316 317 318 int PacmanGhost::graphDistance(Vector3 start, Vector3 goal){ 319 320 Vector3 differenceVector= Vector3(abs(goal.x-start.x), 0,abs(goal.z-start.z)); 321 322 return differenceVector.x+differenceVector.z; 323 } 324 325 void PacmanGhost::updateShortestDistanceToStart(graphVertex &vertex, graphVertex &neighboor){ 326 //apply this method to all non visited neighboors of a vertex. 327 // This method should always be run on a vertex after we marked it as visited. 328 if(neighboor.alreadyVisited==false){ //we only consider non visited neighboors. 329 if((vertex.shortestDistanceToStart!=std::numeric_limits<int>::max())&& 330 (neighboor.shortestDistanceToStart > vertex.shortestDistanceToStart + 331 graphDistance(vertex.position, neighboor.position))){ //need to consider overflow case ! 332 333 neighboor.shortestDistanceToStart= vertex.shortestDistanceToStart + 334 graphDistance(vertex.position, neighboor.position); 335 neighboor.actuelPredecessor = &vertex; 336 } 337 } 338 } 339 340 void PacmanGhost::findNearestNonVisitedNeighboor (graphVertex &vertex, Vector3 pointToAvoidP3){ 341 //find nearest non visited neighboor of a given already visited vertex 342 //(optional parameter) pointToAvoidP3 is a point that cannot be considered 343 int shortestDistance = -1; 344 graphVertex* nearestNonVisitedNeighboor=nullptr;//=graphVertex(); //by default there is not any. 345 //Also, if all neighboors are already visited, we return NULL, i.e. there is no 346 //nearest non visited neighboor. 347 for(int i=0; i < 4; i++){ 348 if((vertex.adjacentVertices[i]!=nullptr)&&(vertex.adjacentVertices[i]->alreadyVisited==false)&&(vertex.adjacentVertices[i]->position!=pointToAvoidP3)){ 349 if(shortestDistance==-1){ //(concerns line above) we want a non visited neighboor //(optional) if the position of the neighboor is the one we want 350 //to avoid, then we ignore it 351 352 shortestDistance= graphDistance(vertex.position, vertex.adjacentVertices[i]->position); 353 nearestNonVisitedNeighboor=vertex.adjacentVertices[i]; //warning, both sides are pointer adresses ! 354 355 } 356 else if(graphDistance(vertex.position, vertex.adjacentVertices[i]->position)<shortestDistance){ 357 shortestDistance= graphDistance(vertex.position, vertex.adjacentVertices[i]->position); 358 nearestNonVisitedNeighboor=vertex.adjacentVertices[i]; //warning, both sides are pointer adresses ! 359 360 } 361 } 362 } 363 vertex.currentNearestNonVisitedNeighboor = nearestNonVisitedNeighboor; //warning, both sides are pointer adresses ! 364 365 } 366 367 368 PacmanGhost::graphVertex* PacmanGhost::findNextVertexToConsider(graphVertex listOfVerticesP[], Vector3 pointToAvoidP2){ //find next, nearest from start, non visited vertex in our listOfVertices array 369 //(optional parameter) pointToAvoidP2 is a point that cannot be considered 370 371 int shortestDistance = -1; 372 graphVertex* nextVertexToConsider; 373 374 for(int i=0; i < 67; i++){ //we loop over all possible positions 375 376 if(listOfVerticesP[i].alreadyVisited==true){ //vertex should already be visited 377 378 findNearestNonVisitedNeighboor(listOfVerticesP[i], pointToAvoidP2); //we update nearest neighboor 379 //of all visited vertices given that one of the nearest neighboor of a visited 380 // vertex is now also visited because it was chosen as next optimal vertex 381 382 if(listOfVerticesP[i].currentNearestNonVisitedNeighboor!=nullptr){ //we want a candidate! 383 if(shortestDistance==-1){ //our first possible candidate 384 385 shortestDistance=graphDistance(listOfVerticesP[i].position, 386 listOfVerticesP[i].currentNearestNonVisitedNeighboor->position) + 387 listOfVerticesP[i].shortestDistanceToStart; 388 389 nextVertexToConsider=listOfVerticesP[i].currentNearestNonVisitedNeighboor; 390 //adress of nextVertexToConsider is that of pointer currentNearestNonVisitedNeighboor 391 392 } 393 else if(shortestDistance > graphDistance(listOfVerticesP[i].position, 394 listOfVerticesP[i].currentNearestNonVisitedNeighboor->position) + 395 listOfVerticesP[i].shortestDistanceToStart){//if better candidate than our first candidate available 396 397 shortestDistance=graphDistance(listOfVerticesP[i].position, 398 listOfVerticesP[i].currentNearestNonVisitedNeighboor->position) + 399 listOfVerticesP[i].shortestDistanceToStart; 400 401 nextVertexToConsider=listOfVerticesP[i].currentNearestNonVisitedNeighboor; 402 //we dont need the & because we are not giving the adress of the array element 403 //listOfVerticesP[i] but that of the pointer currentNearestNonVisitedNeighboor 404 } 405 } 406 } 407 //we want after all to return the nearest non visited neighboor 408 } 409 410 return nextVertexToConsider; //returns adress nextVertexToConsider is pointing to in array 411 } 412 413 ////////////////////////////////////////////////////////////////////////////////////////////// 414 415 void PacmanGhost::findNeighboorVertices(Vector3 actuelposition, graphVertex* adjacentVertices[], graphVertex listOfVerticesP2[]){ 416 //Should put in adjacentVertices the neighboor points of actuelposition. listOfVertices is the 417 //array containing all possible positions in the map. 418 419 if(findpos(actuelposition,possibleposition[0])){ 420 421 adjacentVertices[0]=&listOfVerticesP2[1]; 422 adjacentVertices[1]=&listOfVerticesP2[17]; 423 adjacentVertices[2]=&listOfVerticesP2[19]; 424 } 425 else if(findpos(actuelposition,possibleposition[1])){ 426 adjacentVertices[0]=&listOfVerticesP2[0]; 427 adjacentVertices[1]=&listOfVerticesP2[2]; 428 } 429 else if(findpos(actuelposition,possibleposition[2])){ 430 adjacentVertices[0]=&listOfVerticesP2[1]; 431 adjacentVertices[1]=&listOfVerticesP2[3]; 432 } 433 else if(findpos(actuelposition,possibleposition[3])){ 434 adjacentVertices[0]=&listOfVerticesP2[2]; 435 adjacentVertices[1]=&listOfVerticesP2[4]; 436 adjacentVertices[2]=&listOfVerticesP2[5]; 437 } 438 else if(findpos(actuelposition,possibleposition[4])){ 439 adjacentVertices[0]=&listOfVerticesP2[3]; 440 adjacentVertices[1]=&listOfVerticesP2[6]; 441 } 442 else if(findpos(actuelposition,possibleposition[5])){ 443 adjacentVertices[0]=&listOfVerticesP2[3]; 444 adjacentVertices[1]=&listOfVerticesP2[7]; 445 } 446 else if(findpos(actuelposition,possibleposition[6])){ 447 adjacentVertices[0]=&listOfVerticesP2[4]; 448 adjacentVertices[1]=&listOfVerticesP2[9]; 449 adjacentVertices[2]=&listOfVerticesP2[26]; 450 } 451 else if(findpos(actuelposition,possibleposition[7])){ 452 adjacentVertices[0]=&listOfVerticesP2[5]; 453 adjacentVertices[1]=&listOfVerticesP2[8]; 454 } 455 else if(findpos(actuelposition,possibleposition[8])){ 456 adjacentVertices[0]=&listOfVerticesP2[7]; 457 adjacentVertices[1]=&listOfVerticesP2[9]; 458 } 459 else if(findpos(actuelposition,possibleposition[9])){ 460 adjacentVertices[0]=&listOfVerticesP2[6]; 461 adjacentVertices[1]=&listOfVerticesP2[8]; 462 adjacentVertices[2]=&listOfVerticesP2[10]; 463 adjacentVertices[3]=&listOfVerticesP2[38]; 464 } 465 else if(findpos(actuelposition,possibleposition[10])){ 466 adjacentVertices[0]=&listOfVerticesP2[9]; 467 adjacentVertices[1]=&listOfVerticesP2[11]; 468 adjacentVertices[2]=&listOfVerticesP2[45]; 469 } 470 else if(findpos(actuelposition,possibleposition[11])){ 471 adjacentVertices[0]=&listOfVerticesP2[10]; 472 adjacentVertices[1]=&listOfVerticesP2[12]; 473 adjacentVertices[2]=&listOfVerticesP2[13]; 474 } 475 else if(findpos(actuelposition,possibleposition[12])){ 476 adjacentVertices[0]=&listOfVerticesP2[11]; 477 adjacentVertices[1]=&listOfVerticesP2[14]; 478 } 479 else if(findpos(actuelposition,possibleposition[13])){ 480 adjacentVertices[0]=&listOfVerticesP2[11]; 481 adjacentVertices[1]=&listOfVerticesP2[14]; 482 adjacentVertices[2]=&listOfVerticesP2[16]; 483 adjacentVertices[3]=&listOfVerticesP2[61]; 484 } 485 else if(findpos(actuelposition,possibleposition[14])){ 486 adjacentVertices[0]=&listOfVerticesP2[12]; 487 adjacentVertices[1]=&listOfVerticesP2[13]; 488 adjacentVertices[2]=&listOfVerticesP2[15]; 489 } 490 else if(findpos(actuelposition,possibleposition[15])){ 491 adjacentVertices[0]=&listOfVerticesP2[14]; 492 adjacentVertices[1]=&listOfVerticesP2[16]; 493 } 494 else if(findpos(actuelposition,possibleposition[16])){ 495 adjacentVertices[0]=&listOfVerticesP2[13]; 496 adjacentVertices[1]=&listOfVerticesP2[15]; 497 adjacentVertices[2]=&listOfVerticesP2[62]; 498 } 499 else if(findpos(actuelposition,possibleposition[17])){ 500 adjacentVertices[0]=&listOfVerticesP2[0]; 501 adjacentVertices[1]=&listOfVerticesP2[25]; 502 } 503 else if(findpos(actuelposition,possibleposition[18])){ 504 adjacentVertices[0]=&listOfVerticesP2[19]; 505 adjacentVertices[1]=&listOfVerticesP2[24]; 506 } 507 else if(findpos(actuelposition,possibleposition[19])){ 508 adjacentVertices[0]=&listOfVerticesP2[0]; 509 adjacentVertices[1]=&listOfVerticesP2[18]; 510 adjacentVertices[2]=&listOfVerticesP2[20]; 511 } 512 else if(findpos(actuelposition,possibleposition[20])){ 513 adjacentVertices[0]=&listOfVerticesP2[19]; 514 adjacentVertices[1]=&listOfVerticesP2[21]; 515 } 516 else if(findpos(actuelposition,possibleposition[21])){ 517 adjacentVertices[0]=&listOfVerticesP2[20]; 518 adjacentVertices[1]=&listOfVerticesP2[22]; 519 } 520 else if(findpos(actuelposition,possibleposition[22])){ 521 adjacentVertices[0]=&listOfVerticesP2[21]; 522 adjacentVertices[1]=&listOfVerticesP2[23]; 523 adjacentVertices[2]=&listOfVerticesP2[31]; 524 } 525 else if(findpos(actuelposition,possibleposition[23])){ 526 adjacentVertices[0]=&listOfVerticesP2[22]; 527 adjacentVertices[1]=&listOfVerticesP2[30]; 528 } 529 else if(findpos(actuelposition,possibleposition[24])){ 530 adjacentVertices[0]=&listOfVerticesP2[18]; 531 adjacentVertices[1]=&listOfVerticesP2[29]; 532 } 533 else if(findpos(actuelposition,possibleposition[25])){ 534 adjacentVertices[0]=&listOfVerticesP2[17]; 535 adjacentVertices[1]=&listOfVerticesP2[26]; 536 } 537 else if(findpos(actuelposition,possibleposition[26])){ 538 adjacentVertices[0]=&listOfVerticesP2[6]; 539 adjacentVertices[1]=&listOfVerticesP2[25]; 540 adjacentVertices[2]=&listOfVerticesP2[27]; 541 } 542 else if(findpos(actuelposition,possibleposition[27])){ 543 adjacentVertices[0]=&listOfVerticesP2[26]; 544 adjacentVertices[1]=&listOfVerticesP2[28]; 545 adjacentVertices[2]=&listOfVerticesP2[37]; 546 } 547 else if(findpos(actuelposition,possibleposition[28])){ 548 adjacentVertices[0]=&listOfVerticesP2[27]; 549 adjacentVertices[1]=&listOfVerticesP2[29]; 550 adjacentVertices[2]=&listOfVerticesP2[36]; 551 } 552 else if(findpos(actuelposition,possibleposition[29])){ 553 adjacentVertices[0]=&listOfVerticesP2[24]; 554 adjacentVertices[1]=&listOfVerticesP2[28]; 555 adjacentVertices[2]=&listOfVerticesP2[30]; 556 } 557 else if(findpos(actuelposition,possibleposition[30])){ 558 adjacentVertices[0]=&listOfVerticesP2[23]; 559 adjacentVertices[1]=&listOfVerticesP2[29]; 560 adjacentVertices[2]=&listOfVerticesP2[34]; 561 } 562 else if(findpos(actuelposition,possibleposition[31])){ 563 adjacentVertices[0]=&listOfVerticesP2[22]; 564 adjacentVertices[1]=&listOfVerticesP2[32]; 565 } 566 else if(findpos(actuelposition,possibleposition[32])){ 567 adjacentVertices[0]=&listOfVerticesP2[31]; 568 adjacentVertices[1]=&listOfVerticesP2[33]; 569 } 570 else if(findpos(actuelposition,possibleposition[33])){ 571 adjacentVertices[0]=&listOfVerticesP2[32]; 572 adjacentVertices[1]=&listOfVerticesP2[34]; 573 } 574 else if(findpos(actuelposition,possibleposition[34])){ 575 adjacentVertices[0]=&listOfVerticesP2[30]; 576 adjacentVertices[1]=&listOfVerticesP2[33]; 577 adjacentVertices[2]=&listOfVerticesP2[35]; 578 adjacentVertices[3]=&listOfVerticesP2[42]; 579 580 } 581 else if(findpos(actuelposition,possibleposition[35])){ 582 adjacentVertices[0]=&listOfVerticesP2[34]; 583 adjacentVertices[1]=&listOfVerticesP2[36]; 584 adjacentVertices[2]=&listOfVerticesP2[41]; 585 } 586 else if(findpos(actuelposition,possibleposition[36])){ 587 adjacentVertices[0]=&listOfVerticesP2[28]; 588 adjacentVertices[1]=&listOfVerticesP2[35]; 589 } 590 else if(findpos(actuelposition,possibleposition[37])){ 591 adjacentVertices[0]=&listOfVerticesP2[27]; 592 adjacentVertices[1]=&listOfVerticesP2[38]; 593 } 594 else if(findpos(actuelposition,possibleposition[38])){ 595 adjacentVertices[0]=&listOfVerticesP2[9]; 596 adjacentVertices[1]=&listOfVerticesP2[37]; 597 adjacentVertices[2]=&listOfVerticesP2[39]; 598 } 599 else if(findpos(actuelposition,possibleposition[39])){ 600 adjacentVertices[0]=&listOfVerticesP2[38]; 601 adjacentVertices[1]=&listOfVerticesP2[40]; 602 adjacentVertices[2]=&listOfVerticesP2[45]; 603 } 604 else if(findpos(actuelposition,possibleposition[40])){ 605 adjacentVertices[0]=&listOfVerticesP2[39]; 606 adjacentVertices[1]=&listOfVerticesP2[41]; 607 } 608 else if(findpos(actuelposition,possibleposition[41])){ 609 adjacentVertices[0]=&listOfVerticesP2[35]; 610 adjacentVertices[1]=&listOfVerticesP2[43]; 611 adjacentVertices[2]=&listOfVerticesP2[40]; 612 } 613 else if(findpos(actuelposition,possibleposition[42])){ 614 adjacentVertices[0]=&listOfVerticesP2[34]; 615 adjacentVertices[1]=&listOfVerticesP2[43]; 616 adjacentVertices[2]=&listOfVerticesP2[54]; 617 } 618 else if(findpos(actuelposition,possibleposition[43])){ 619 adjacentVertices[0]=&listOfVerticesP2[41]; 620 adjacentVertices[1]=&listOfVerticesP2[46]; 621 adjacentVertices[2]=&listOfVerticesP2[42]; 622 } 623 else if(findpos(actuelposition,possibleposition[44])){ 624 adjacentVertices[0]=&listOfVerticesP2[40]; 625 adjacentVertices[1]=&listOfVerticesP2[66]; 626 } 627 else if(findpos(actuelposition,possibleposition[45])){ 628 adjacentVertices[0]=&listOfVerticesP2[10]; 629 adjacentVertices[1]=&listOfVerticesP2[39]; 630 adjacentVertices[2]=&listOfVerticesP2[49]; 631 } 632 else if(findpos(actuelposition,possibleposition[46])){ 633 adjacentVertices[0]=&listOfVerticesP2[43]; 634 adjacentVertices[1]=&listOfVerticesP2[47]; 635 } 636 else if(findpos(actuelposition,possibleposition[47])){ 637 adjacentVertices[0]=&listOfVerticesP2[46]; 638 adjacentVertices[1]=&listOfVerticesP2[52]; 639 adjacentVertices[2]=&listOfVerticesP2[66]; 640 } 641 else if(findpos(actuelposition,possibleposition[48])){ 642 adjacentVertices[0]=&listOfVerticesP2[49]; 643 adjacentVertices[1]=&listOfVerticesP2[51]; 644 adjacentVertices[2]=&listOfVerticesP2[66]; 645 } 646 else if(findpos(actuelposition,possibleposition[49])){ 647 adjacentVertices[0]=&listOfVerticesP2[45]; 648 adjacentVertices[1]=&listOfVerticesP2[48]; 649 } 650 else if(findpos(actuelposition,possibleposition[50])){ 651 adjacentVertices[0]=&listOfVerticesP2[51]; 652 adjacentVertices[1]=&listOfVerticesP2[61]; 653 } 654 else if(findpos(actuelposition,possibleposition[51])){ 655 adjacentVertices[0]=&listOfVerticesP2[48]; 656 adjacentVertices[1]=&listOfVerticesP2[50]; 657 } 658 else if(findpos(actuelposition,possibleposition[52])){ 659 adjacentVertices[0]=&listOfVerticesP2[47]; 660 adjacentVertices[1]=&listOfVerticesP2[53]; 661 } 662 else if(findpos(actuelposition,possibleposition[53])){ 663 adjacentVertices[0]=&listOfVerticesP2[52]; 664 adjacentVertices[1]=&listOfVerticesP2[58]; 665 } 666 else if(findpos(actuelposition,possibleposition[54])){ 667 adjacentVertices[0]=&listOfVerticesP2[42]; 668 adjacentVertices[1]=&listOfVerticesP2[55]; 669 adjacentVertices[2]=&listOfVerticesP2[57]; 670 } 671 else if(findpos(actuelposition,possibleposition[55])){ 672 adjacentVertices[0]=&listOfVerticesP2[54]; 673 adjacentVertices[1]=&listOfVerticesP2[56]; 674 } 675 else if(findpos(actuelposition,possibleposition[56])){ 676 adjacentVertices[0]=&listOfVerticesP2[55]; 677 adjacentVertices[1]=&listOfVerticesP2[57]; 678 adjacentVertices[2]=&listOfVerticesP2[65]; 679 } 680 else if(findpos(actuelposition,possibleposition[57])){ 681 adjacentVertices[0]=&listOfVerticesP2[54]; 682 adjacentVertices[1]=&listOfVerticesP2[56]; 683 adjacentVertices[2]=&listOfVerticesP2[58]; 684 adjacentVertices[3]=&listOfVerticesP2[64]; 685 686 } 687 else if(findpos(actuelposition,possibleposition[58])){ 688 adjacentVertices[0]=&listOfVerticesP2[53]; 689 adjacentVertices[1]=&listOfVerticesP2[57]; 690 adjacentVertices[2]=&listOfVerticesP2[59]; 691 } 692 else if(findpos(actuelposition,possibleposition[59])){ 693 adjacentVertices[0]=&listOfVerticesP2[58]; 694 adjacentVertices[1]=&listOfVerticesP2[60]; 695 adjacentVertices[2]=&listOfVerticesP2[63]; 696 } 697 else if(findpos(actuelposition,possibleposition[60])){ 698 adjacentVertices[0]=&listOfVerticesP2[59]; 699 adjacentVertices[1]=&listOfVerticesP2[61]; 700 adjacentVertices[2]=&listOfVerticesP2[62]; 701 } 702 else if(findpos(actuelposition,possibleposition[61])){ 703 adjacentVertices[0]=&listOfVerticesP2[13]; 704 adjacentVertices[1]=&listOfVerticesP2[50]; 705 adjacentVertices[2]=&listOfVerticesP2[60]; 706 } 707 else if(findpos(actuelposition,possibleposition[62])){ 708 adjacentVertices[0]=&listOfVerticesP2[16]; 709 adjacentVertices[1]=&listOfVerticesP2[60]; 710 } 711 else if(findpos(actuelposition,possibleposition[63])){ 712 adjacentVertices[0]=&listOfVerticesP2[59]; 713 adjacentVertices[1]=&listOfVerticesP2[64]; 714 } 715 else if(findpos(actuelposition,possibleposition[64])){ 716 adjacentVertices[0]=&listOfVerticesP2[57]; 717 adjacentVertices[1]=&listOfVerticesP2[63]; 718 adjacentVertices[2]=&listOfVerticesP2[65]; 719 } 720 else if(findpos(actuelposition,possibleposition[65])){ 721 adjacentVertices[0]=&listOfVerticesP2[56]; 722 adjacentVertices[1]=&listOfVerticesP2[64]; 723 } 724 else if(findpos(actuelposition,possibleposition[66])){ 725 adjacentVertices[0]=&listOfVerticesP2[47]; 726 adjacentVertices[1]=&listOfVerticesP2[48]; 727 } 728 } 729 730 731 Vector3 PacmanGhost::frontPosition(){ 732 //Should return the Vector3 point in front of the player. 733 734 Vector3 neighborPos[4] = {Vector3(-1,-1,-1)}; 735 Vector3 frontPoint = Vector3(0,-1,0); 736 737 738 findNeighboorPositions(this->lastPlayerPassedPoint, neighborPos, possibleposition); 739 740 for(int i=0; i<4; i++){ 741 742 if((neighborPos[i]!=Vector3(-1,-1,-1))&&(neighborPos[i].y==10)){ 743 //y==10 to ignore many unwanted strange positions that pop up otherwise and create SIGSEV 744 745 if(frontPoint==Vector3(0,-1,0)){ 746 frontPoint=neighborPos[i]; 747 748 } 749 else if (graphDistance(this->getPlayerPos(), frontPoint)>graphDistance(this->getPlayerPos(), neighborPos[i])){ 750 frontPoint=neighborPos[i]; 751 } 752 753 } 754 } 755 756 if(frontPoint==Vector3(0,-1,0)){ 757 //default 758 return this->lastPlayerPassedPoint; 759 } 760 else{ 761 return frontPoint; 762 } 763 } 764 765 766 767 768 769 770 void PacmanGhost::findNeighboorPositions(Vector3 actuelposition, Vector3 adjacentPositions[], Vector3 positionArray[]){ 771 //this function should put in adjacentPositions[] the neighboors of actuelposition. 772 // positionArray[] contains all possible positions of the map. 773 774 if(findpos(actuelposition,possibleposition[0])){ 775 776 777 adjacentPositions[0]=positionArray[1]; 778 adjacentPositions[1]=positionArray[17]; 779 adjacentPositions[2]=positionArray[19]; 780 } 781 else if(findpos(actuelposition,possibleposition[1])){ 782 adjacentPositions[0]=positionArray[0]; 783 adjacentPositions[1]=positionArray[2]; 784 } 785 else if(findpos(actuelposition,possibleposition[2])){ 786 adjacentPositions[0]=positionArray[1]; 787 adjacentPositions[1]=positionArray[3]; 788 } 789 else if(findpos(actuelposition,possibleposition[3])){ 790 adjacentPositions[0]=positionArray[2]; 791 adjacentPositions[1]=positionArray[4]; 792 adjacentPositions[2]=positionArray[5]; 793 } 794 else if(findpos(actuelposition,possibleposition[4])){ 795 adjacentPositions[0]=positionArray[3]; 796 adjacentPositions[1]=positionArray[6]; 797 } 798 else if(findpos(actuelposition,possibleposition[5])){ 799 adjacentPositions[0]=positionArray[3]; 800 adjacentPositions[1]=positionArray[7]; 801 } 802 else if(findpos(actuelposition,possibleposition[6])){ 803 adjacentPositions[0]=positionArray[4]; ; 804 adjacentPositions[1]=positionArray[9]; 805 adjacentPositions[2]=positionArray[26]; 806 } 807 else if(findpos(actuelposition,possibleposition[7])){ 808 adjacentPositions[0]=positionArray[5]; 809 adjacentPositions[1]=positionArray[8]; 810 } 811 else if(findpos(actuelposition,possibleposition[8])){ 812 adjacentPositions[0]=positionArray[7]; 813 adjacentPositions[1]=positionArray[9]; 814 } 815 else if(findpos(actuelposition,possibleposition[9])){ 816 adjacentPositions[0]=positionArray[6]; 817 adjacentPositions[1]=positionArray[8]; 818 adjacentPositions[2]=positionArray[10]; 819 adjacentPositions[3]=positionArray[38]; 820 } 821 else if(findpos(actuelposition,possibleposition[10])){ 822 adjacentPositions[0]=positionArray[9]; 823 adjacentPositions[1]=positionArray[11]; 824 adjacentPositions[2]=positionArray[45]; 825 } 826 else if(findpos(actuelposition,possibleposition[11])){ 827 adjacentPositions[0]=positionArray[10]; 828 adjacentPositions[1]=positionArray[12]; 829 adjacentPositions[2]=positionArray[13]; 830 } 831 else if(findpos(actuelposition,possibleposition[12])){ 832 adjacentPositions[0]=positionArray[11]; 833 adjacentPositions[1]=positionArray[14]; 834 } 835 else if(findpos(actuelposition,possibleposition[13])){ 836 adjacentPositions[0]=positionArray[11]; 837 adjacentPositions[1]=positionArray[14]; 838 adjacentPositions[2]=positionArray[16]; 839 adjacentPositions[3]=positionArray[61]; 840 } 841 else if(findpos(actuelposition,possibleposition[14])){ 842 adjacentPositions[0]=positionArray[12]; 843 adjacentPositions[1]=positionArray[13]; 844 adjacentPositions[2]=positionArray[15]; 845 } 846 else if(findpos(actuelposition,possibleposition[15])){ 847 adjacentPositions[0]=positionArray[14]; 848 adjacentPositions[1]=positionArray[16]; 849 } 850 else if(findpos(actuelposition,possibleposition[16])){ 851 adjacentPositions[0]=positionArray[13]; 852 adjacentPositions[1]=positionArray[15]; 853 adjacentPositions[2]=positionArray[62]; 854 } 855 else if(findpos(actuelposition,possibleposition[17])){ 856 adjacentPositions[0]=positionArray[0]; 857 adjacentPositions[1]=positionArray[25]; 858 } 859 else if(findpos(actuelposition,possibleposition[18])){ 860 adjacentPositions[0]=positionArray[19]; 861 adjacentPositions[1]=positionArray[24]; 862 } 863 else if(findpos(actuelposition,possibleposition[19])){ 864 adjacentPositions[0]=positionArray[0]; 865 adjacentPositions[1]=positionArray[18]; 866 adjacentPositions[2]=positionArray[20]; 867 } 868 else if(findpos(actuelposition,possibleposition[20])){ 869 adjacentPositions[0]=positionArray[19]; 870 adjacentPositions[1]=positionArray[21]; 871 } 872 else if(findpos(actuelposition,possibleposition[21])){ 873 adjacentPositions[0]=positionArray[20]; 874 adjacentPositions[1]=positionArray[22]; 875 } 876 else if(findpos(actuelposition,possibleposition[22])){ 877 adjacentPositions[0]=positionArray[21]; 878 adjacentPositions[1]=positionArray[23]; 879 adjacentPositions[2]=positionArray[31]; 880 } 881 else if(findpos(actuelposition,possibleposition[23])){ 882 adjacentPositions[0]=positionArray[22]; 883 adjacentPositions[1]=positionArray[30]; 884 } 885 else if(findpos(actuelposition,possibleposition[24])){ 886 adjacentPositions[0]=positionArray[18]; 887 adjacentPositions[1]=positionArray[29]; 888 } 889 else if(findpos(actuelposition,possibleposition[25])){ 890 adjacentPositions[0]=positionArray[17]; 891 adjacentPositions[1]=positionArray[26]; 892 } 893 else if(findpos(actuelposition,possibleposition[26])){ 894 adjacentPositions[0]=positionArray[6]; 895 adjacentPositions[1]=positionArray[25]; 896 adjacentPositions[2]=positionArray[27]; 897 } 898 else if(findpos(actuelposition,possibleposition[27])){ 899 adjacentPositions[0]=positionArray[26]; 900 adjacentPositions[1]=positionArray[28]; 901 adjacentPositions[2]=positionArray[37]; 902 } 903 else if(findpos(actuelposition,possibleposition[28])){ 904 adjacentPositions[0]=positionArray[27]; 905 adjacentPositions[1]=positionArray[29]; 906 adjacentPositions[2]=positionArray[36]; 907 } 908 else if(findpos(actuelposition,possibleposition[29])){ 909 adjacentPositions[0]=positionArray[24]; 910 adjacentPositions[1]=positionArray[28]; 911 adjacentPositions[2]=positionArray[30]; 912 } 913 else if(findpos(actuelposition,possibleposition[30])){ 914 adjacentPositions[0]=positionArray[23]; 915 adjacentPositions[1]=positionArray[29]; 916 adjacentPositions[2]=positionArray[34]; 917 } 918 else if(findpos(actuelposition,possibleposition[31])){ 919 adjacentPositions[0]=positionArray[22]; 920 adjacentPositions[1]=positionArray[32]; 921 } 922 else if(findpos(actuelposition,possibleposition[32])){ 923 adjacentPositions[0]=positionArray[31]; 924 adjacentPositions[1]=positionArray[33]; 925 } 926 else if(findpos(actuelposition,possibleposition[33])){ 927 adjacentPositions[0]=positionArray[32]; 928 adjacentPositions[1]=positionArray[34]; 929 } 930 else if(findpos(actuelposition,possibleposition[34])){ 931 adjacentPositions[0]=positionArray[30]; 932 adjacentPositions[1]=positionArray[33]; 933 adjacentPositions[2]=positionArray[35]; 934 adjacentPositions[3]=positionArray[42]; 935 936 } 937 else if(findpos(actuelposition,possibleposition[35])){ 938 adjacentPositions[0]=positionArray[34]; 939 adjacentPositions[1]=positionArray[36]; 940 adjacentPositions[2]=positionArray[41]; 941 } 942 else if(findpos(actuelposition,possibleposition[36])){ 943 adjacentPositions[0]=positionArray[28]; 944 adjacentPositions[1]=positionArray[35]; 945 } 946 else if(findpos(actuelposition,possibleposition[37])){ 947 adjacentPositions[0]=positionArray[27]; 948 adjacentPositions[1]=positionArray[38]; 949 } 950 else if(findpos(actuelposition,possibleposition[38])){ 951 adjacentPositions[0]=positionArray[9]; 952 adjacentPositions[1]=positionArray[37]; 953 adjacentPositions[2]=positionArray[39]; 954 } 955 else if(findpos(actuelposition,possibleposition[39])){ 956 adjacentPositions[0]=positionArray[38]; 957 adjacentPositions[1]=positionArray[40]; 958 adjacentPositions[2]=positionArray[45]; 959 } 960 else if(findpos(actuelposition,possibleposition[40])){ 961 adjacentPositions[0]=positionArray[39]; 962 adjacentPositions[1]=positionArray[41]; 963 } 964 else if(findpos(actuelposition,possibleposition[41])){ 965 adjacentPositions[0]=positionArray[35]; 966 adjacentPositions[1]=positionArray[43]; 967 adjacentPositions[2]=positionArray[40]; 968 } 969 else if(findpos(actuelposition,possibleposition[42])){ 970 adjacentPositions[0]=positionArray[34]; 971 adjacentPositions[1]=positionArray[43]; 972 adjacentPositions[2]=positionArray[54]; 973 } 974 else if(findpos(actuelposition,possibleposition[43])){ 975 adjacentPositions[0]=positionArray[41]; 976 adjacentPositions[1]=positionArray[46]; 977 adjacentPositions[2]=positionArray[42]; 978 } 979 else if(findpos(actuelposition,possibleposition[44])){ 980 adjacentPositions[0]=positionArray[40]; 981 adjacentPositions[1]=positionArray[66]; 982 } 983 else if(findpos(actuelposition,possibleposition[45])){ 984 adjacentPositions[0]=positionArray[10]; 985 adjacentPositions[1]=positionArray[39]; 986 adjacentPositions[2]=positionArray[49]; 987 } 988 else if(findpos(actuelposition,possibleposition[46])){ 989 adjacentPositions[0]=positionArray[43]; 990 adjacentPositions[1]=positionArray[47]; 991 } 992 else if(findpos(actuelposition,possibleposition[47])){ 993 adjacentPositions[0]=positionArray[46]; 994 adjacentPositions[1]=positionArray[52]; 995 adjacentPositions[2]=positionArray[66]; 996 } 997 else if(findpos(actuelposition,possibleposition[48])){ 998 adjacentPositions[0]=positionArray[49]; 999 adjacentPositions[1]=positionArray[51]; 1000 adjacentPositions[2]=positionArray[66]; 1001 } 1002 else if(findpos(actuelposition,possibleposition[49])){ 1003 adjacentPositions[0]=positionArray[45]; 1004 adjacentPositions[1]=positionArray[48]; 1005 } 1006 else if(findpos(actuelposition,possibleposition[50])){ 1007 adjacentPositions[0]=positionArray[51]; 1008 adjacentPositions[1]=positionArray[61]; 1009 } 1010 else if(findpos(actuelposition,possibleposition[51])){ 1011 adjacentPositions[0]=positionArray[48]; 1012 adjacentPositions[1]=positionArray[50]; 1013 } 1014 else if(findpos(actuelposition,possibleposition[52])){ 1015 adjacentPositions[0]=positionArray[47]; 1016 adjacentPositions[1]=positionArray[53]; 1017 } 1018 else if(findpos(actuelposition,possibleposition[53])){ 1019 adjacentPositions[0]=positionArray[52]; 1020 adjacentPositions[1]=positionArray[58]; 1021 } 1022 else if(findpos(actuelposition,possibleposition[54])){ 1023 adjacentPositions[0]=positionArray[42]; 1024 adjacentPositions[1]=positionArray[55]; 1025 adjacentPositions[2]=positionArray[57]; 1026 } 1027 else if(findpos(actuelposition,possibleposition[55])){ 1028 adjacentPositions[0]=positionArray[54]; 1029 adjacentPositions[1]=positionArray[56]; 1030 } 1031 else if(findpos(actuelposition,possibleposition[56])){ 1032 adjacentPositions[0]=positionArray[55]; 1033 adjacentPositions[1]=positionArray[57]; 1034 adjacentPositions[2]=positionArray[65]; 1035 } 1036 else if(findpos(actuelposition,possibleposition[57])){ 1037 adjacentPositions[0]=positionArray[54]; 1038 adjacentPositions[1]=positionArray[56]; 1039 adjacentPositions[2]=positionArray[58]; 1040 adjacentPositions[3]=positionArray[64]; 1041 1042 } 1043 else if(findpos(actuelposition,possibleposition[58])){ 1044 adjacentPositions[0]=positionArray[53]; 1045 adjacentPositions[1]=positionArray[57]; 1046 adjacentPositions[2]=positionArray[59]; 1047 } 1048 else if(findpos(actuelposition,possibleposition[59])){ 1049 adjacentPositions[0]=positionArray[58]; 1050 adjacentPositions[1]=positionArray[60]; 1051 adjacentPositions[2]=positionArray[63]; 1052 } 1053 else if(findpos(actuelposition,possibleposition[60])){ 1054 adjacentPositions[0]=positionArray[59]; 1055 adjacentPositions[1]=positionArray[61]; 1056 adjacentPositions[2]=positionArray[62]; 1057 } 1058 else if(findpos(actuelposition,possibleposition[61])){ 1059 adjacentPositions[0]=positionArray[13]; 1060 adjacentPositions[1]=positionArray[50]; 1061 adjacentPositions[2]=positionArray[60]; 1062 } 1063 else if(findpos(actuelposition,possibleposition[62])){ 1064 adjacentPositions[0]=positionArray[16]; 1065 adjacentPositions[1]=positionArray[60]; 1066 } 1067 else if(findpos(actuelposition,possibleposition[63])){ 1068 adjacentPositions[0]=positionArray[59]; 1069 adjacentPositions[1]=positionArray[64]; 1070 } 1071 else if(findpos(actuelposition,possibleposition[64])){ 1072 adjacentPositions[0]=positionArray[57]; 1073 adjacentPositions[1]=positionArray[63]; 1074 adjacentPositions[2]=positionArray[65]; 1075 } 1076 else if(findpos(actuelposition,possibleposition[65])){ 1077 adjacentPositions[0]=positionArray[56]; 1078 adjacentPositions[1]=positionArray[64]; 1079 } 1080 else if(findpos(actuelposition,possibleposition[66])){ 1081 adjacentPositions[0]=positionArray[47]; 1082 adjacentPositions[1]=positionArray[48]; 1083 } 1084 } 1085 1086 497 1087 } -
code/branches/Presentation_FS19/src/modules/pacman/PacmanGhost.h
r12290 r12408 36 36 #include "worldentities/ControllableEntity.h" 37 37 38 #include "Pacman.h" 39 38 40 namespace orxonox { 41 42 extern Vector3 possibleposition[67]; 43 44 extern bool findpos(Vector3 one, Vector3 other); 45 46 47 48 39 49 40 50 class _OrxonoxExport PacmanGhost : public ControllableEntity … … 44 54 virtual ~PacmanGhost(); 45 55 46 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) ; //!< Method for creating an AutonomousDrone through XML.47 virtual void tick(float dt); //!< Defines which actions the AutonomousDrone has to take in each tick.56 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) ; //!< Method for creating an AutonomousDrone through XML. 57 //virtual void tick(float dt); //!< Defines which actions the AutonomousDrone has to take in each tick. 48 58 49 v oid move(float dt, Vector3 actuelposition, Vector3 velocity);59 virtual void move(float dt, Vector3 actuelposition, Vector3 velocity); 50 60 51 v oid resetGhost();61 virtual void resetGhost(); 52 62 53 void changewith(PacmanGhost* otherghost); 54 void levelupvelo(); 55 56 bool findpos(Vector3 one, Vector3 other); 57 void changemovability(); 63 virtual void changewith(PacmanGhost* otherghost); 64 virtual void levelupvelo(); 65 66 virtual void changemovability(); 58 67 bool dontmove = false; 59 68 60 private:69 61 70 int decision = 0; 62 71 Vector3 resetposition = Vector3(0,10,15); … … 70 79 bool lockmove = false; 71 80 72 void setnewTarget(int firstdec); 73 void setnewTarget(int firstdec, int seconddec); 74 void setnewTarget(int firstdec, int seconddec, int thirddec); 75 void setnewTarget(int firstdec, int seconddec, int thirddec, int fourthdec); 81 82 Vector3 getPlayerPos(); 83 84 Vector3 playerPos; 85 86 Vector3 lastPlayerPassedPoint; 87 88 Vector3 pointInFrontOfPlayer; 89 90 /* 91 public: //HACK 92 */ 93 94 95 struct graphVertex; 96 void findNeighboorVertices(Vector3 actuelposition, graphVertex* adjacentVertices[], graphVertex listOfVerticesP2[]); 97 void updateShortestDistanceToStart(graphVertex &vertex, graphVertex &neighboor); 98 void findNearestNonVisitedNeighboor (graphVertex &vertex, Vector3 pointToAvoidP3=Vector3(0,0,0)); 99 int graphDistance(Vector3 start, Vector3 goal); 100 101 graphVertex* findNextVertexToConsider(graphVertex listOfVerticesP[], Vector3 pointToAvoidP2=Vector3(0,0,0)); 102 Vector3 getShortestPath(Vector3 start, Vector3 goal, Vector3 pointToAvoidP1=Vector3(0,0,0)); 103 104 105 106 Vector3 getPointInFrontOfPacman(Vector3 pacLasVisPos,int indexForSWNE); 107 int findPlayerTravDir (Vector3 playerPosBefore, Vector3 playerPos); 108 Vector3 diffVector (Vector3 start, Vector3 goal); 109 110 bool playerFindPos(Vector3 one, Vector3 other); 111 112 bool jeanfindpos(Vector3 one, Vector3 other); 113 114 void setNewTargetGhost(Vector3 goalToGo); 115 116 117 118 119 120 void findNeighboorPositions(Vector3 actuelposition, Vector3 adjacentPositions[], Vector3 positionArray[]); 121 122 Vector3 frontPosition(); 123 76 124 }; 77 125 -
code/branches/Presentation_FS19/src/modules/pacman/PacmanPointSphere.cc
r12009 r12408 82 82 return false; 83 83 } 84 85 84 //Reset position 86 85 void PacmanPointSphere::resetPacmanPointSphere(){
Note: See TracChangeset
for help on using the changeset viewer.