Changeset 11915 for code/branches/3DPacman_FS18/src
- Timestamp:
- Apr 26, 2018, 4:11:19 PM (7 years ago)
- Location:
- code/branches/3DPacman_FS18/src/modules/pacman
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/3DPacman_FS18/src/modules/pacman/CMakeLists.txt
r11898 r11915 1 SET_SOURCE_FILES(PICKUP_SRC_FILES 2 1 SET_SOURCE_FILES(Pacman_SRC_FILES 3 2 Pacman.cc 4 3 PacmanGhost.cc … … 7 6 ) 8 7 9 ORXONOX_ADD_LIBRARY( Pacman10 MODULE8 ORXONOX_ADD_LIBRARY(pacman 9 PLUGIN 11 10 FIND_HEADER_FILES 12 11 TOLUA_FILES … … 17 16 orxonox 18 17 objects 19 pickup 20 SOURCE_FILES ${PICKUP_SRC_FILES} 18 SOURCE_FILES ${Pacman_SRC_FILES} 21 19 ) -
code/branches/3DPacman_FS18/src/modules/pacman/Pacman.cc
r11898 r11915 38 38 namespace orxonox 39 39 { 40 Register UnloadableClass(Pacman);40 RegisterClass(Pacman); 41 41 42 42 Pacman::Pacman(Context* context) : Deathmatch(context) … … 44 44 RegisterObject(Pacman); 45 45 46 lives = 3;46 lives = 10; 47 47 point = 0; 48 48 level = 1; … … 57 57 58 58 PacmanGhost* ghosts[4]; 59 PacmanPointSphere* spheres[1];60 59 61 60 62 61 void Pacman::tick(float dt) 63 62 { 63 SUPER(Pacman, tick, dt); 64 64 65 int i = 0; 65 66 for(PacmanGhost* nextghost : ObjectList<PacmanGhost>()){ … … 74 75 } 75 76 77 76 78 bcolli = false; 77 79 for(int nrghost = 0; (nrghost<3) && (!bcolli); ++nrghost){ 78 80 bcolli = collis(ghosts[nrghost]->getPosition(), currentPosition); 81 //orxout() << "GHOST" << nrghost << ghosts[nrghost]->getPosition() << endl; 79 82 } 83 80 84 if(bcolli){ 81 85 this->catched(); 82 86 } 83 87 … … 89 93 } 90 94 91 SUPER(Pacman, tick, dt);92 93 95 } 94 96 95 97 96 98 bool Pacman::collis(Vector3 one, Vector3 other){ 97 if((abs(one.x-other.x)< 0.1) && (abs(one.x-other.x)<0.1) && (abs(one.x-other.x)<0.1))99 if((abs(one.x-other.x)<7) && (abs(one.y-other.y)<7) && (abs(one.z-other.z)<7)) 98 100 return true; 99 101 return false; … … 107 109 108 110 void Pacman::posreset(){ 109 int i = 0;110 111 for(PacmanGhost* nextghost : ObjectList<PacmanGhost>()){ 111 112 nextghost->resetGhost(); 112 i++;113 113 } 114 114 player->setPosition(startposplayer); … … 118 118 ++point; 119 119 if(point == totallevelpoint) this->levelUp(); 120 121 120 Vector3 postaken = taken->getPosition(); 122 121 postaken.y = -50; … … 141 140 void Pacman::start() 142 141 { 143 orxout() << "start" << endl;144 145 142 Deathmatch::start(); 146 }147 148 void Pacman::playerPreSpawn(PlayerInfo* player)149 {150 //PlayerInfo* playerInfo_;151 //this->playerInfo_ = player;152 if(lives <= 0)153 {154 this->end();155 }156 143 } 157 144 -
code/branches/3DPacman_FS18/src/modules/pacman/Pacman.h
r11898 r11915 72 72 virtual void tick(float dt) override; 73 73 74 virtual void playerPreSpawn(PlayerInfo* player) override;75 76 74 void levelUp(); 77 75 bool collis(Vector3 one, Vector3 other); … … 95 93 bool bcolli = false; 96 94 Vector3 startposplayer = Vector3(0,10,245); 97 int totallevelpoint = 1;95 int totallevelpoint = 3; 98 96 99 97 private: -
code/branches/3DPacman_FS18/src/modules/pacman/PacmanGhost.cc
r11904 r11915 50 50 this->setCollisionType(CollisionType::Dynamic); 51 51 52 this->resetposition = Vector3(0,20,245); //Set Default start position52 this->resetposition = this->getPosition(); //Set Default start position 53 53 54 54 this->actuelposition = this->getPosition(); … … 81 81 82 82 83 Vector3 possibleposition[] = {Vector3(175,10,245),Vector3(215,10,245),Vector3(215,10,195),Vector3(185,10,195),Vector3(135,10,195), 84 Vector3(185,10,150),Vector3(135,10,145),Vector3(215,10,150)}; 83 Vector3 possibleposition[] = {Vector3(20,10,245),Vector3(215,10,245),Vector3(215,10,195),Vector3(185,10,195),Vector3(135,10,195), //0-4 84 Vector3(185,10,150),Vector3(135,10,150),Vector3(215,10,150),Vector3(215,10,105),Vector3(135,10,105), //5-9 85 Vector3(135,10,15),Vector3(135,10,-85),Vector3(215,10,-85),Vector3(135,10,-135),Vector3(215,10,-135), //10-14 86 Vector3(215,10,-195),Vector3(135,10,-195),Vector3(20,10,195),Vector3(-20,10,195),Vector3(-20,10,245), //15-19 87 Vector3(-215,10,245),Vector3(-215,10,195),Vector3(-185,10,195),Vector3(-135,10,195),Vector3(-70,10,195), //20-24 88 Vector3(70,10,195),Vector3(70,10,150),Vector3(20,10,150),Vector3(-20,10,150),Vector3(-70,10,150), //25-29 89 Vector3(-135,10,150),Vector3(-185,10,150),Vector3(-215,10,150),Vector3(-215,10,105),Vector3(-135,10,105) //30-34 90 }; 85 91 86 92 /** … … 99 105 100 106 //Stop, if target arrived 101 if((abs(this->actuelposition.x - this->target_x)<0. 1) && (abs(this->actuelposition.z - this->target_z)<0.1)){107 if((abs(this->actuelposition.x - this->target_x)<0.5) && (abs(this->actuelposition.z - this->target_z)<0.5)){ 102 108 this->ismoving = false; 103 109 } … … 105 111 //Move, if ghost hasn't arrived yet 106 112 if(this->ismoving){ 107 if(!(abs(this->actuelposition.z-target_z)<0. 1)) {108 velocity = Vector3(0,0,-sgn(this->actuelposition.z-this->target_z) );113 if(!(abs(this->actuelposition.z-target_z)<0.5)) { 114 velocity = Vector3(0,0,-sgn(this->actuelposition.z-this->target_z)*2); 109 115 move(dt, actuelposition, velocity); 110 116 } 111 if(!(abs(this->actuelposition.x-target_x)<0. 1)){112 velocity = Vector3(-sgn(this->actuelposition.x-this->target_x) ,0,0);117 if(!(abs(this->actuelposition.x-target_x)<0.5)){ 118 velocity = Vector3(-sgn(this->actuelposition.x-this->target_x)*2,0,0); 113 119 move(dt, actuelposition, velocity); 114 120 } … … 118 124 else{ 119 125 if(findpos(actuelposition,possibleposition[0])){ 120 setnewTarget(1 );126 setnewTarget(1,17,19); 121 127 } 122 128 else if(findpos(actuelposition,possibleposition[1])){ … … 136 142 } 137 143 else if(findpos(actuelposition,possibleposition[6])){ 138 setnewTarget(4 );144 setnewTarget(4,9,26); 139 145 } 140 146 else if(findpos(actuelposition,possibleposition[7])){ 141 setnewTarget(5); 147 setnewTarget(5,8); 148 } 149 else if(findpos(actuelposition,possibleposition[8])){ 150 setnewTarget(7,9); 151 } 152 else if(findpos(actuelposition,possibleposition[9])){ 153 setnewTarget(6,8,10); //38 154 } 155 else if(findpos(actuelposition,possibleposition[10])){ 156 setnewTarget(9,11); //45,9 157 } 158 else if(findpos(actuelposition,possibleposition[11])){ 159 setnewTarget(10,12,13); 160 } 161 else if(findpos(actuelposition,possibleposition[12])){ 162 setnewTarget(11,14); 163 } 164 else if(findpos(actuelposition,possibleposition[13])){ 165 setnewTarget(11,14,16); //61 166 } 167 else if(findpos(actuelposition,possibleposition[14])){ 168 setnewTarget(12,13,15); 169 } 170 else if(findpos(actuelposition,possibleposition[15])){ 171 setnewTarget(14,16); 172 } 173 else if(findpos(actuelposition,possibleposition[16])){ 174 setnewTarget(13,15); //62 175 } 176 else if(findpos(actuelposition,possibleposition[17])){ 177 setnewTarget(0,25); 178 } 179 else if(findpos(actuelposition,possibleposition[18])){ 180 setnewTarget(19,24); 181 } 182 else if(findpos(actuelposition,possibleposition[19])){ 183 setnewTarget(0,18,20); 184 } 185 else if(findpos(actuelposition,possibleposition[20])){ 186 setnewTarget(19,21); 187 } 188 else if(findpos(actuelposition,possibleposition[21])){ 189 setnewTarget(20,22); 190 } 191 else if(findpos(actuelposition,possibleposition[22])){ 192 setnewTarget(21,23,31); 193 } 194 else if(findpos(actuelposition,possibleposition[23])){ 195 setnewTarget(22,30); 196 } 197 else if(findpos(actuelposition,possibleposition[24])){ 198 setnewTarget(18,29); 199 } 200 else if(findpos(actuelposition,possibleposition[25])){ 201 setnewTarget(17,26); 202 } 203 else if(findpos(actuelposition,possibleposition[26])){ 204 setnewTarget(6,25,27); 205 } 206 else if(findpos(actuelposition,possibleposition[27])){ 207 setnewTarget(26,28);//37 208 } 209 else if(findpos(actuelposition,possibleposition[28])){ 210 setnewTarget(27,29); //36 211 } 212 else if(findpos(actuelposition,possibleposition[29])){ 213 setnewTarget(24,28,30); 214 } 215 else if(findpos(actuelposition,possibleposition[30])){ 216 setnewTarget(23,29,34); 217 } 218 else if(findpos(actuelposition,possibleposition[31])){ 219 setnewTarget(22,32); 220 } 221 else if(findpos(actuelposition,possibleposition[32])){ 222 setnewTarget(31,33); 223 } 224 else if(findpos(actuelposition,possibleposition[33])){ 225 setnewTarget(32,34); 226 } 227 else if(findpos(actuelposition,possibleposition[34])){ 228 setnewTarget(30,33);//35,42 142 229 } 143 230 … … 230 317 231 318 bool PacmanGhost::findpos(Vector3 one, Vector3 other){ 232 if((abs(one.x - other.x)<0. 1) && (abs(one.z - other.z)<0.1)) return true;319 if((abs(one.x - other.x)<0.5) && (abs(one.z - other.z)<0.5)) return true; 233 320 return false; 234 321 } 235 322 236 323 void PacmanGhost::resetGhost(){ 237 this->setPosition(resetposition); 324 this->setPosition(this->resetposition); 325 this->ismoving = false; 326 this->actuelposition = this->getPosition(); 327 328 this->target_x = actuelposition.x; 329 this->target_z = actuelposition.z; 238 330 } 239 331 } 240 241 /*242 //Check on which position ghost has arrived and set new target243 else{244 if(findpos(actuelposition,possibleposition[0])){245 decision = rand()%1;246 switch(decision){247 case 0:248 this->target_x = possibleposition[1].x;249 this->target_z = possibleposition[1].z;250 this->ismoving = true;251 break;252 }253 254 }255 else if(findpos(actuelposition,possibleposition[1])){256 decision = rand()%2;257 switch(decision){258 case 0:259 this->target_x = possibleposition[0].x;260 this->target_z = possibleposition[0].z;261 this->ismoving = true;262 break;263 case 1:264 this->target_x = possibleposition[2].x;265 this->target_z = possibleposition[2].z;266 this->ismoving = true;267 break;268 }269 270 }271 else if(findpos(actuelposition,possibleposition[2])){272 decision = rand()%2;273 switch(decision){274 case 0:275 this->target_x = possibleposition[1].x;276 this->target_z = possibleposition[1].z;277 this->ismoving = true;278 break;279 case 1:280 this->target_x = possibleposition[3].x;281 this->target_z = possibleposition[3].z;282 this->ismoving = true;283 break;284 }285 286 }287 288 else if(findpos(actuelposition,possibleposition[3])){289 decision = rand()%3;290 switch(decision){291 case 0:292 this->target_x = possibleposition[2].x;293 this->target_z = possibleposition[2].z;294 this->ismoving = true;295 break;296 case 1:297 this->target_x = possibleposition[4].x;298 this->target_z = possibleposition[4].z;299 this->ismoving = true;300 break;301 case 2:302 this->target_x = possibleposition[5].x;303 this->target_z = possibleposition[5].z;304 this->ismoving = true;305 break;306 }307 }308 309 else if(findpos(actuelposition,possibleposition[4])){310 decision = rand()%2;311 switch(decision){312 case 0:313 this->target_x = possibleposition[3].x;314 this->target_z = possibleposition[3].z;315 this->ismoving = true;316 break;317 case 1:318 this->target_x = possibleposition[6].x;319 this->target_z = possibleposition[6].z;320 this->ismoving = true;321 break;322 }323 }324 325 else if(findpos(actuelposition,possibleposition[5])){326 decision = rand()%2;327 switch(decision){328 case 0:329 this->target_x = possibleposition[3].x;330 this->target_z = possibleposition[3].z;331 this->ismoving = true;332 break;333 case 1:334 this->target_x = possibleposition[7].x;335 this->target_z = possibleposition[7].z;336 this->ismoving = true;337 break;338 }339 }340 341 else if(findpos(actuelposition,possibleposition[6])){342 decision = rand()%1;343 switch(decision){344 case 0:345 this->target_x = possibleposition[4].x;346 this->target_z = possibleposition[4].z;347 this->ismoving = true;348 break;349 }350 }351 352 else if(findpos(actuelposition,possibleposition[7])){353 decision = rand()%1;354 switch(decision){355 case 0:356 this->target_x = possibleposition[5].x;357 this->target_z = possibleposition[5].z;358 this->ismoving = true;359 break;360 }361 }362 363 364 else{365 } //End of Position table366 */ -
code/branches/3DPacman_FS18/src/modules/pacman/PacmanPointSphere.cc
r11898 r11915 64 64 { 65 65 SUPER(PacmanPointSphere, XMLPort, xmlelement, mode); 66 67 XMLPortParam(PacmanPointSphere, "resetposition", setResetPosition, getResetPosition, xmlelement, mode);68 66 } 69 67 -
code/branches/3DPacman_FS18/src/modules/pacman/PacmanPointSphere.h
r11898 r11915 49 49 bool taken(Vector3 playerpos); 50 50 void resetPacmanPointSphere(); 51 52 inline void setResetPosition(Vector3 rpos)53 { this->resetposition = rpos; }54 55 inline Vector3 getResetPosition()56 { return this->resetposition; }57 58 51 private: 59 52
Note: See TracChangeset
for help on using the changeset viewer.