[11898] | 1 | /* |
---|
| 2 | * ORXONOX - the hottest 3D action shooter ever to exist |
---|
| 3 | * > www.orxonox.net < |
---|
| 4 | * |
---|
| 5 | * |
---|
| 6 | * License notice: |
---|
| 7 | * |
---|
| 8 | * This program is free software; you can redistribute it and/or |
---|
| 9 | * modify it under the terms of the GNU General Public License |
---|
| 10 | * as published by the Free Software Foundation; either version 2 |
---|
| 11 | * of the License, or (at your option) any later version. |
---|
| 12 | * |
---|
| 13 | * This program is distributed in the hope that it will be useful, |
---|
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 16 | * GNU General Public License for more details. |
---|
| 17 | * |
---|
| 18 | * You should have received a copy of the GNU General Public License |
---|
| 19 | * along with this program; if not, write to the Free Software |
---|
| 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
---|
| 21 | * |
---|
| 22 | * Author: |
---|
| 23 | * Oli Scheuss |
---|
| 24 | * Co-authors: |
---|
| 25 | * Damian 'Mozork' Frick |
---|
| 26 | * |
---|
| 27 | */ |
---|
| 28 | |
---|
| 29 | #include "PacmanGhost.h" |
---|
| 30 | |
---|
| 31 | #include "core/CoreIncludes.h" |
---|
| 32 | #include "BulletDynamics/Dynamics/btRigidBody.h" |
---|
| 33 | |
---|
| 34 | namespace orxonox |
---|
| 35 | { |
---|
| 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 | |
---|
[11927] | 48 | this->velocity = Vector3(0, 0, 0); |
---|
[11898] | 49 | |
---|
| 50 | this->setCollisionType(CollisionType::Dynamic); |
---|
| 51 | |
---|
| 52 | this->actuelposition = this->getPosition(); |
---|
[11945] | 53 | |
---|
| 54 | if(findpos(actuelposition, Vector3(0,-20,0))) |
---|
| 55 | dontmove = true; |
---|
[11898] | 56 | |
---|
| 57 | this->target_x = actuelposition.x; |
---|
[11927] | 58 | this->target_z = actuelposition.z; |
---|
[11898] | 59 | |
---|
| 60 | } |
---|
| 61 | |
---|
| 62 | /** |
---|
| 63 | @brief |
---|
| 64 | Destructor. Destroys controller, 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 AutonomousDrone through XML. |
---|
| 74 | */ |
---|
| 75 | void PacmanGhost::XMLPort(Element& xmlelement, XMLPort::Mode mode) |
---|
| 76 | { |
---|
| 77 | SUPER(PacmanGhost, XMLPort, xmlelement, mode); |
---|
| 78 | } |
---|
| 79 | |
---|
| 80 | |
---|
[11924] | 81 | |
---|
[11915] | 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 |
---|
[11926] | 88 | Vector3(-135,10,150),Vector3(-185,10,150),Vector3(-215,10,150),Vector3(-215,10,105),Vector3(-135,10,105), //30-34 |
---|
[11917] | 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 |
---|
[11925] | 95 | Vector3(-215,10,-195),Vector3(0,10,-35)}; //65-66 |
---|
[11924] | 96 | |
---|
[11898] | 97 | /** |
---|
| 98 | @brief |
---|
| 99 | Defines which actions the AutonomousDrone 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 | //setorientation |
---|
[11927] | 108 | |
---|
[11898] | 109 | this->actuelposition = this->getPosition(); |
---|
| 110 | |
---|
| 111 | //Stop, if target arrived |
---|
[11915] | 112 | if((abs(this->actuelposition.x - this->target_x)<0.5) && (abs(this->actuelposition.z - this->target_z)<0.5)){ |
---|
[11898] | 113 | this->ismoving = false; |
---|
| 114 | } |
---|
| 115 | |
---|
| 116 | //Move, if ghost hasn't arrived yet |
---|
| 117 | if(this->ismoving){ |
---|
[11915] | 118 | if(!(abs(this->actuelposition.z-target_z)<0.5)) { |
---|
[11979] | 119 | velocity = Vector3(0,0,-sgn(this->actuelposition.z-this->target_z)); |
---|
[11898] | 120 | move(dt, actuelposition, velocity); |
---|
| 121 | } |
---|
[11915] | 122 | if(!(abs(this->actuelposition.x-target_x)<0.5)){ |
---|
[11979] | 123 | velocity = Vector3(-sgn(this->actuelposition.x-this->target_x),0,0); |
---|
[11898] | 124 | move(dt, actuelposition, velocity); |
---|
| 125 | } |
---|
| 126 | } |
---|
| 127 | //Check on which position ghost has arrived and set new target |
---|
| 128 | else{ |
---|
[11952] | 129 | while(lockmove){}; |
---|
| 130 | lockmove = true; |
---|
| 131 | |
---|
[11900] | 132 | if(findpos(actuelposition,possibleposition[0])){ |
---|
[11915] | 133 | setnewTarget(1,17,19); |
---|
[11903] | 134 | } |
---|
| 135 | else if(findpos(actuelposition,possibleposition[1])){ |
---|
| 136 | setnewTarget(0,2); |
---|
| 137 | } |
---|
| 138 | else if(findpos(actuelposition,possibleposition[2])){ |
---|
| 139 | setnewTarget(1,3); |
---|
| 140 | } |
---|
| 141 | else if(findpos(actuelposition,possibleposition[3])){ |
---|
| 142 | setnewTarget(2,4,5); |
---|
| 143 | } |
---|
| 144 | else if(findpos(actuelposition,possibleposition[4])){ |
---|
| 145 | setnewTarget(3,6); |
---|
| 146 | } |
---|
| 147 | else if(findpos(actuelposition,possibleposition[5])){ |
---|
| 148 | setnewTarget(3,7); |
---|
| 149 | } |
---|
| 150 | else if(findpos(actuelposition,possibleposition[6])){ |
---|
[11915] | 151 | setnewTarget(4,9,26); |
---|
[11903] | 152 | } |
---|
| 153 | else if(findpos(actuelposition,possibleposition[7])){ |
---|
[11915] | 154 | setnewTarget(5,8); |
---|
[11903] | 155 | } |
---|
[11915] | 156 | else if(findpos(actuelposition,possibleposition[8])){ |
---|
| 157 | setnewTarget(7,9); |
---|
| 158 | } |
---|
| 159 | else if(findpos(actuelposition,possibleposition[9])){ |
---|
[11917] | 160 | setnewTarget(6,8,10,38); |
---|
[11915] | 161 | } |
---|
| 162 | else if(findpos(actuelposition,possibleposition[10])){ |
---|
[11917] | 163 | setnewTarget(9,11,45); |
---|
[11915] | 164 | } |
---|
| 165 | else if(findpos(actuelposition,possibleposition[11])){ |
---|
| 166 | setnewTarget(10,12,13); |
---|
| 167 | } |
---|
| 168 | else if(findpos(actuelposition,possibleposition[12])){ |
---|
| 169 | setnewTarget(11,14); |
---|
| 170 | } |
---|
| 171 | else if(findpos(actuelposition,possibleposition[13])){ |
---|
[11917] | 172 | setnewTarget(11,14,16,61); |
---|
[11915] | 173 | } |
---|
| 174 | else if(findpos(actuelposition,possibleposition[14])){ |
---|
| 175 | setnewTarget(12,13,15); |
---|
| 176 | } |
---|
| 177 | else if(findpos(actuelposition,possibleposition[15])){ |
---|
| 178 | setnewTarget(14,16); |
---|
| 179 | } |
---|
| 180 | else if(findpos(actuelposition,possibleposition[16])){ |
---|
[11917] | 181 | setnewTarget(13,15,62); |
---|
[11915] | 182 | } |
---|
| 183 | else if(findpos(actuelposition,possibleposition[17])){ |
---|
| 184 | setnewTarget(0,25); |
---|
| 185 | } |
---|
| 186 | else if(findpos(actuelposition,possibleposition[18])){ |
---|
| 187 | setnewTarget(19,24); |
---|
| 188 | } |
---|
| 189 | else if(findpos(actuelposition,possibleposition[19])){ |
---|
| 190 | setnewTarget(0,18,20); |
---|
| 191 | } |
---|
| 192 | else if(findpos(actuelposition,possibleposition[20])){ |
---|
| 193 | setnewTarget(19,21); |
---|
| 194 | } |
---|
| 195 | else if(findpos(actuelposition,possibleposition[21])){ |
---|
| 196 | setnewTarget(20,22); |
---|
| 197 | } |
---|
| 198 | else if(findpos(actuelposition,possibleposition[22])){ |
---|
| 199 | setnewTarget(21,23,31); |
---|
| 200 | } |
---|
| 201 | else if(findpos(actuelposition,possibleposition[23])){ |
---|
| 202 | setnewTarget(22,30); |
---|
| 203 | } |
---|
| 204 | else if(findpos(actuelposition,possibleposition[24])){ |
---|
| 205 | setnewTarget(18,29); |
---|
| 206 | } |
---|
| 207 | else if(findpos(actuelposition,possibleposition[25])){ |
---|
| 208 | setnewTarget(17,26); |
---|
| 209 | } |
---|
| 210 | else if(findpos(actuelposition,possibleposition[26])){ |
---|
| 211 | setnewTarget(6,25,27); |
---|
| 212 | } |
---|
| 213 | else if(findpos(actuelposition,possibleposition[27])){ |
---|
[11917] | 214 | setnewTarget(26,28,37); |
---|
[11915] | 215 | } |
---|
| 216 | else if(findpos(actuelposition,possibleposition[28])){ |
---|
[11917] | 217 | setnewTarget(27,29,36); |
---|
[11915] | 218 | } |
---|
| 219 | else if(findpos(actuelposition,possibleposition[29])){ |
---|
| 220 | setnewTarget(24,28,30); |
---|
| 221 | } |
---|
| 222 | else if(findpos(actuelposition,possibleposition[30])){ |
---|
| 223 | setnewTarget(23,29,34); |
---|
| 224 | } |
---|
| 225 | else if(findpos(actuelposition,possibleposition[31])){ |
---|
| 226 | setnewTarget(22,32); |
---|
| 227 | } |
---|
| 228 | else if(findpos(actuelposition,possibleposition[32])){ |
---|
| 229 | setnewTarget(31,33); |
---|
| 230 | } |
---|
| 231 | else if(findpos(actuelposition,possibleposition[33])){ |
---|
| 232 | setnewTarget(32,34); |
---|
| 233 | } |
---|
| 234 | else if(findpos(actuelposition,possibleposition[34])){ |
---|
[11917] | 235 | setnewTarget(30,33,35,42); |
---|
[11915] | 236 | } |
---|
[11917] | 237 | else if(findpos(actuelposition,possibleposition[35])){ |
---|
| 238 | setnewTarget(34,36,41); |
---|
| 239 | } |
---|
| 240 | else if(findpos(actuelposition,possibleposition[36])){ |
---|
| 241 | setnewTarget(28,35); |
---|
| 242 | } |
---|
| 243 | else if(findpos(actuelposition,possibleposition[37])){ |
---|
| 244 | setnewTarget(27,38); |
---|
| 245 | } |
---|
| 246 | else if(findpos(actuelposition,possibleposition[38])){ |
---|
| 247 | setnewTarget(9,37,39); |
---|
| 248 | } |
---|
| 249 | else if(findpos(actuelposition,possibleposition[39])){ |
---|
| 250 | setnewTarget(38,40,45); |
---|
| 251 | } |
---|
| 252 | else if(findpos(actuelposition,possibleposition[40])){ |
---|
| 253 | setnewTarget(39,41); //Shouldn't be able to return in center |
---|
| 254 | } |
---|
| 255 | else if(findpos(actuelposition,possibleposition[41])){ |
---|
| 256 | setnewTarget(35,43); |
---|
| 257 | } |
---|
| 258 | else if(findpos(actuelposition,possibleposition[42])){ |
---|
| 259 | setnewTarget(34,43,54); |
---|
| 260 | } |
---|
| 261 | else if(findpos(actuelposition,possibleposition[43])){ |
---|
| 262 | setnewTarget(41,46); |
---|
| 263 | } |
---|
| 264 | else if(findpos(actuelposition,possibleposition[44])){ |
---|
| 265 | setnewTarget(40,66); |
---|
| 266 | } |
---|
| 267 | else if(findpos(actuelposition,possibleposition[45])){ |
---|
| 268 | setnewTarget(10,39,49); |
---|
| 269 | } |
---|
| 270 | else if(findpos(actuelposition,possibleposition[46])){ |
---|
| 271 | setnewTarget(43,47); |
---|
| 272 | } |
---|
| 273 | else if(findpos(actuelposition,possibleposition[47])){ |
---|
| 274 | setnewTarget(46,52,66); |
---|
| 275 | } |
---|
| 276 | else if(findpos(actuelposition,possibleposition[48])){ |
---|
| 277 | setnewTarget(49,51,66); |
---|
| 278 | } |
---|
| 279 | else if(findpos(actuelposition,possibleposition[49])){ |
---|
| 280 | setnewTarget(45,48); |
---|
| 281 | } |
---|
| 282 | else if(findpos(actuelposition,possibleposition[50])){ |
---|
| 283 | setnewTarget(51,61); |
---|
| 284 | } |
---|
| 285 | else if(findpos(actuelposition,possibleposition[51])){ |
---|
| 286 | setnewTarget(48,50); |
---|
| 287 | } |
---|
| 288 | else if(findpos(actuelposition,possibleposition[52])){ |
---|
| 289 | setnewTarget(47,53); |
---|
| 290 | } |
---|
| 291 | else if(findpos(actuelposition,possibleposition[53])){ |
---|
| 292 | setnewTarget(52,58); |
---|
| 293 | } |
---|
| 294 | else if(findpos(actuelposition,possibleposition[54])){ |
---|
| 295 | setnewTarget(42,55,57); |
---|
| 296 | } |
---|
| 297 | else if(findpos(actuelposition,possibleposition[55])){ |
---|
| 298 | setnewTarget(54,56); |
---|
| 299 | } |
---|
| 300 | else if(findpos(actuelposition,possibleposition[56])){ |
---|
| 301 | setnewTarget(55,57,65); |
---|
| 302 | } |
---|
| 303 | else if(findpos(actuelposition,possibleposition[57])){ |
---|
| 304 | setnewTarget(54,56,58,64); |
---|
| 305 | } |
---|
| 306 | else if(findpos(actuelposition,possibleposition[58])){ |
---|
| 307 | setnewTarget(53,57,59); |
---|
| 308 | } |
---|
| 309 | else if(findpos(actuelposition,possibleposition[59])){ |
---|
| 310 | setnewTarget(58,59,63); |
---|
| 311 | } |
---|
| 312 | else if(findpos(actuelposition,possibleposition[60])){ |
---|
| 313 | setnewTarget(59,61,62); |
---|
| 314 | } |
---|
| 315 | else if(findpos(actuelposition,possibleposition[61])){ |
---|
| 316 | setnewTarget(13,50,60); |
---|
| 317 | } |
---|
| 318 | else if(findpos(actuelposition,possibleposition[62])){ |
---|
| 319 | setnewTarget(16,60); |
---|
| 320 | } |
---|
| 321 | else if(findpos(actuelposition,possibleposition[63])){ |
---|
| 322 | setnewTarget(59,64); |
---|
| 323 | } |
---|
| 324 | else if(findpos(actuelposition,possibleposition[64])){ |
---|
| 325 | setnewTarget(57,63,65); |
---|
| 326 | } |
---|
| 327 | else if(findpos(actuelposition,possibleposition[65])){ |
---|
| 328 | setnewTarget(56,64); |
---|
| 329 | } |
---|
[11931] | 330 | else if(findpos(actuelposition,possibleposition[66])){ |
---|
| 331 | setnewTarget(47,48); |
---|
| 332 | } |
---|
[11903] | 333 | |
---|
| 334 | else{ |
---|
[11917] | 335 | this->resetGhost(); //Shouldn't happen... |
---|
[11903] | 336 | } //End of Position table |
---|
[11952] | 337 | lockmove = false; |
---|
[11903] | 338 | } |
---|
[11952] | 339 | |
---|
[11903] | 340 | } |
---|
| 341 | |
---|
| 342 | void PacmanGhost::setnewTarget(int firstdec){ |
---|
[11923] | 343 | |
---|
[11903] | 344 | decision = rand()%1; |
---|
| 345 | switch(decision){ |
---|
| 346 | case 0: |
---|
| 347 | this->target_x = possibleposition[firstdec].x; |
---|
| 348 | this->target_z = possibleposition[firstdec].z; |
---|
| 349 | this->ismoving = true; |
---|
| 350 | break; |
---|
| 351 | } |
---|
| 352 | } |
---|
| 353 | |
---|
[11927] | 354 | void PacmanGhost::setnewTarget(int firstdec, int seconddec){ |
---|
[11903] | 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 | } |
---|
[11927] | 368 | |
---|
[11903] | 369 | } |
---|
| 370 | |
---|
| 371 | void PacmanGhost::setnewTarget(int firstdec, int seconddec, int thirddec){ |
---|
[11927] | 372 | |
---|
[11903] | 373 | decision = rand()%3; |
---|
| 374 | switch(decision){ |
---|
| 375 | case 0: |
---|
| 376 | this->target_x = possibleposition[firstdec].x; |
---|
| 377 | this->target_z = possibleposition[firstdec].z; |
---|
| 378 | this->ismoving = true; |
---|
| 379 | break; |
---|
| 380 | case 1: |
---|
| 381 | this->target_x = possibleposition[seconddec].x; |
---|
| 382 | this->target_z = possibleposition[seconddec].z; |
---|
| 383 | this->ismoving = true; |
---|
| 384 | break; |
---|
| 385 | case 2: |
---|
| 386 | this->target_x = possibleposition[thirddec].x; |
---|
| 387 | this->target_z = possibleposition[thirddec].z; |
---|
| 388 | this->ismoving = true; |
---|
| 389 | break; |
---|
| 390 | } |
---|
[11927] | 391 | |
---|
[11903] | 392 | } |
---|
| 393 | |
---|
| 394 | void PacmanGhost::setnewTarget(int firstdec, int seconddec, int thirddec, int fourthdec){ |
---|
[11927] | 395 | |
---|
[11903] | 396 | decision = rand()%4; |
---|
| 397 | switch(decision){ |
---|
| 398 | case 0: |
---|
| 399 | this->target_x = possibleposition[firstdec].x; |
---|
| 400 | this->target_z = possibleposition[firstdec].z; |
---|
| 401 | this->ismoving = true; |
---|
| 402 | break; |
---|
| 403 | case 1: |
---|
| 404 | this->target_x = possibleposition[seconddec].x; |
---|
| 405 | this->target_z = possibleposition[seconddec].z; |
---|
| 406 | this->ismoving = true; |
---|
| 407 | break; |
---|
| 408 | case 2: |
---|
| 409 | this->target_x = possibleposition[thirddec].x; |
---|
| 410 | this->target_z = possibleposition[thirddec].z; |
---|
| 411 | this->ismoving = true; |
---|
| 412 | break; |
---|
| 413 | case 3: |
---|
| 414 | this->target_x = possibleposition[fourthdec].x; |
---|
| 415 | this->target_z = possibleposition[fourthdec].z; |
---|
| 416 | this->ismoving = true; |
---|
| 417 | break; |
---|
| 418 | } |
---|
[11927] | 419 | |
---|
[11903] | 420 | } |
---|
| 421 | |
---|
[11947] | 422 | void PacmanGhost::changewith(PacmanGhost* otherghost){ |
---|
[11949] | 423 | |
---|
[11950] | 424 | while(lockmove){}; |
---|
| 425 | lockmove = true; |
---|
[11949] | 426 | |
---|
[11945] | 427 | otherghost->setPosition(this->getPosition()); |
---|
| 428 | this->setPosition(0,-20,0); |
---|
| 429 | otherghost->target_x = this->target_x; //Probleme bei parallelen Porzessen |
---|
[11948] | 430 | otherghost->target_z = this->target_z; |
---|
[11945] | 431 | otherghost->ismoving = this->ismoving; |
---|
[11903] | 432 | |
---|
[11945] | 433 | this->dontmove = true; |
---|
| 434 | otherghost->dontmove = false; |
---|
[11949] | 435 | |
---|
[11950] | 436 | lockmove = false; |
---|
[11945] | 437 | } |
---|
[11903] | 438 | |
---|
[11945] | 439 | |
---|
[11903] | 440 | void PacmanGhost::move(float dt, Vector3 actuelposition, Vector3 velocity){ |
---|
[11976] | 441 | if(!dontmove){ |
---|
[11979] | 442 | this->setPosition(Vector3(actuelposition.x+speed*velocity.x*dt,10,actuelposition.z+speed*velocity.z*dt)); |
---|
| 443 | if((abs(abs(velocity.x)-1)<0.1) && (abs(velocity.z-0)<0.1)) |
---|
[11978] | 444 | if(velocity.x<0){ |
---|
| 445 | this->setOrientation(Quaternion(Radian(-1.57), Vector3(0, 1, 0))); |
---|
[11976] | 446 | } |
---|
[11978] | 447 | else{ |
---|
| 448 | this->setOrientation(Quaternion(Radian(1.57), Vector3(0, 1, 0))); |
---|
[11976] | 449 | } |
---|
[11979] | 450 | if((abs(abs(velocity.z)-1)<0.1) && (abs(velocity.x-0)<0.1)) |
---|
[11978] | 451 | if(velocity.z<0){ |
---|
| 452 | this->setOrientation(Quaternion(Radian(3.14), Vector3(0, 1, 0))); |
---|
[11976] | 453 | } |
---|
[11978] | 454 | else{ |
---|
| 455 | this->setOrientation(Quaternion(Radian(0), Vector3(0, 1, 0))); |
---|
| 456 | } |
---|
| 457 | this->getOrientation(); |
---|
| 458 | |
---|
[11976] | 459 | } |
---|
[11903] | 460 | } |
---|
| 461 | |
---|
| 462 | bool PacmanGhost::findpos(Vector3 one, Vector3 other){ |
---|
[11945] | 463 | if((abs(one.x - other.x)<0.5) && (abs(one.y - other.y)<0.5) && (abs(one.z - other.z)<0.5)) return true; |
---|
[11922] | 464 | return false; |
---|
[11903] | 465 | } |
---|
| 466 | |
---|
[11944] | 467 | void PacmanGhost::changemovability(){ |
---|
[11933] | 468 | if(dontmove){ |
---|
| 469 | dontmove = false;} |
---|
| 470 | else{ |
---|
| 471 | dontmove = true; |
---|
| 472 | } |
---|
| 473 | } |
---|
| 474 | |
---|
[11903] | 475 | void PacmanGhost::resetGhost(){ |
---|
[11927] | 476 | |
---|
[11915] | 477 | this->setPosition(this->resetposition); |
---|
| 478 | this->ismoving = false; |
---|
| 479 | this->actuelposition = this->getPosition(); |
---|
| 480 | |
---|
| 481 | this->target_x = actuelposition.x; |
---|
| 482 | this->target_z = actuelposition.z; |
---|
[11927] | 483 | |
---|
[11903] | 484 | } |
---|
[11958] | 485 | |
---|
[11959] | 486 | void PacmanGhost::levelupvelo(){ |
---|
[11979] | 487 | speed ++; |
---|
[11958] | 488 | } |
---|
[11915] | 489 | } |
---|