- Timestamp:
- Dec 16, 2017, 12:24:20 PM (7 years ago)
- Location:
- code/branches/Presentation_HS17
- Files:
-
- 11 edited
- 4 copied
Legend:
- Unmodified
- Added
- Removed
-
code/branches/Presentation_HS17
- Property svn:mergeinfo changed
-
code/branches/Presentation_HS17/src/modules/superorxobros/CMakeLists.txt
r11416 r11678 9 9 SOBHUDInfo.cc 10 10 SOBGumba.cc 11 SOBFireball.cc 11 12 SOBFlagstone.cc 12 13 SOBCastlestone.cc 13 14 SOBCoin.cc 15 SOBGumbaBoss.cc 14 16 15 17 ) -
code/branches/Presentation_HS17/src/modules/superorxobros/SOB.cc
r11418 r11678 44 44 #include "SOBFigure.h" 45 45 #include "graphics/Camera.h" 46 #include "Highscore.h" 46 47 47 48 … … 49 50 namespace orxonox 50 51 { 51 52 bool newHighscore=0; 52 53 RegisterUnloadableClass(SOB); 53 54 … … 124 125 GSLevel::startMainMenu(); 125 126 Deathmatch::end(); 126 127 } 127 128 128 129 void SOB::restart() { … … 167 168 if (this->figure_ != nullptr && figure_->lvlEnded_) { 168 169 std::stringstream a; 169 a << "Nice! " << getPoints() << " Points in " << (400-getTimeLeft())/2 <<"s.\n\nPress <Space> to restart"; 170 if(!newHighscore){ 171 a << "Nice! " << getPoints() << " Points in " << (400-getTimeLeft())/2 <<"s.\n\nPress <Space> to restart"; 172 } 173 else{ 174 a << "Congrats, new Highscore! " << getPoints() << " Points in " << (400-getTimeLeft())/2 <<"s.\n\nPress <Space> to restart"; 175 } 170 176 info_ =a.str(); 171 177 -
code/branches/Presentation_HS17/src/modules/superorxobros/SOB.h
r11418 r11678 76 76 points_+=100; 77 77 } 78 void addGumbaBoss() { 79 points_+=5000; 80 } 78 81 void addPoints(int poi) { 79 82 points_+=poi; … … 103 106 104 107 WeakPtr<SOBCenterpoint> center_; 108 bool newHighscore; 105 109 106 110 protected: -
code/branches/Presentation_HS17/src/modules/superorxobros/SOBFigure.cc
r11420 r11678 23 23 * Julien Kindle 24 24 * Co-authors: 25 * Noah Zarro 26 * Theo von Arx 25 27 * 26 28 * … … 39 41 #include "graphics/Camera.h" 40 42 #include "graphics/ParticleSpawner.h" 43 #include <OgreMath.h> 41 44 42 45 #include "SOBMushroom.h" 43 46 #include "SOBGumba.h" 47 #include "SOBGumbaBoss.h" 48 #include "SOBFireball.h" 44 49 #include "SOB.h" 45 50 #include "SOBFlagstone.h" 46 51 #include "SOBCastlestone.h" 52 #include "SOBFireball.h" 53 #include "Highscore.h" 47 54 #include <BulletCollision/NarrowPhaseCollision/btManifoldPoint.h> 48 55 … … 59 66 60 67 //Vars for movement of player 61 moveUpPressed_ = false; 62 moveDownPressed_ = false; 63 moveLeftPressed_ = false; 64 moveDownPressed_ = false; 65 firePressed_ = false; 66 collDisZ_ = 0; 68 moveUpPressed_ = false; 69 moveDownPressed_ = false; 70 moveLeftPressed_ = false; 71 moveDownPressed_ = false; 72 firePressed_ = false; 73 collDisZ_ = 0; 74 67 75 //Times and turning 68 timeSinceLastFire_ = 0.0;69 lastSpeed_z = 0.0;70 pitch_ = 0.0;71 timeCounter_ = 0;76 timeSinceLastFire_ = 0.0; 77 lastSpeed_z = 0.0; 78 pitch_ = 0.0; 79 timeCounter_ = 0; 72 80 73 81 //Properties of player 74 gotPowerUp_ = false; 75 isColliding_ = true;76 particlespawner_ = NULL;82 83 isColliding_ = true; 84 particlespawner_ = NULL; 77 85 78 86 //Properties of players life 79 predead_ = false;80 dead_ = false;81 lvlEnded_ = false;87 predead_ = false; 88 dead_ = false; 89 lvlEnded_ = false; 82 90 reachedLvlEndState_ = 0; 91 92 // Properties concerning PowerUps and items 93 PowerUpCounter_ = 0; 94 maxPowerUp_ = 2; 95 FireballPower = 2; 96 //Properties of fireing Fireballs, NOTE! fireballs are fired with the moveUP Key, not with the fire key 97 fireallowed_ = true; 98 firecooldown_ = 0; 83 99 84 100 … … 97 113 98 114 //Orxocast returns object with casted type if otherObject has that class, and if not a nullptr 99 SOBMushroom* mush = orxonox_cast<SOBMushroom*>(otherObject); 100 SOBGumba* gumba = orxonox_cast<SOBGumba*>(otherObject); 101 SOBFlagstone* flagstone = orxonox_cast<SOBFlagstone*>(otherObject); 102 SOBCastlestone* castlestone = orxonox_cast<SOBCastlestone*>(otherObject); 103 104 //Check if otherObject is a powerup 115 SOBMushroom* mush = orxonox_cast<SOBMushroom*> (otherObject); 116 SOBGumba* gumba = orxonox_cast<SOBGumba*> (otherObject); 117 SOBGumbaBoss* gumbaBoss = orxonox_cast<SOBGumbaBoss*> (otherObject); 118 SOBFlagstone* flagstone = orxonox_cast<SOBFlagstone*> (otherObject); 119 SOBCastlestone* castlestone = orxonox_cast<SOBCastlestone*> (otherObject); 120 SOBFireball* fireball = orxonox_cast<SOBFireball*> (otherObject); 121 SOB* SOBGame = orxonox_cast<SOB*> (getGametype()); 122 123 124 //Check if otherObject is a powerup-mushroom 105 125 if (mush != nullptr && !(mush->hasCollided_)) { 106 126 otherObject->destroyLater(); 107 gotPowerUp_ = true; 108 SOB* SOBGame = orxonox_cast<SOB*>(getGametype()); //Get the Gametype 127 128 PowerUpCounter_++; 129 if(PowerUpCounter_ > maxPowerUp_) PowerUpCounter_ = maxPowerUp_; // you had already the max 130 else this->changeClothes(); 131 109 132 SOBGame->addMushroom(); // Tell the gametype to increase points 110 133 mush->hasCollided_ = true; // needed because of destroyLater takes some time and player should receive points only once 134 135 136 } 137 138 111 139 112 140 //Check if otherObject is a Gumba (that walking enemies) 113 } else if (gumba != nullptr && !(gumba->hasCollided_)) { 114 115 //If player jumps on its head, kill it, else, kill the player 141 142 else if (gumba != nullptr && gumbaBoss == nullptr && !(gumba->hasCollided_)) { 143 144 //If player jumps on its head, kill the Gumba, else, kill the player 116 145 if (getVelocity().z >= -20) { 117 Vector3 vel = getVelocity(); 118 vel.y = -80; 119 vel.z = 200; 120 setVelocity(vel); 121 predead_=true; 122 SOB* SOBGame = orxonox_cast<SOB*>(getGametype()); 123 SOBGame->setDone(true); 146 // If player hasn't a power up, he dies. Else he shrinks and the gumba dies. 147 if(PowerUpCounter_ == 0){ 148 this->die(); 149 } 150 else{ 151 PowerUpCounter_--; 152 this->changeClothes(); 153 154 gumba->destroyLater(); 155 gumba->hasCollided_ = true; 156 } 124 157 125 158 } else { 126 159 gumba->destroyLater(); 127 160 gumba->hasCollided_ = true; 128 SOB* SOBGame = orxonox_cast<SOB*>(getGametype());129 161 SOBGame->addGumba(); 130 162 131 163 132 } 133 } 164 } 165 } 166 else if (gumbaBoss != nullptr && !(gumbaBoss->hasCollided_)) { 167 if (getVelocity().z >= -20) { 168 // If player hasn't a power up, he dies. Else he dies directly. 169 this->die(); 170 } 171 172 else { 173 gumbaBoss->destroyLater(); 174 gumbaBoss->hasCollided_ = true; 175 SOBGame->addGumbaBoss(); 176 } 177 } 178 else if (fireball != nullptr && !(fireball->hasCollided_)){ 179 if(PowerUpCounter_ == 0){ 180 this->die(); 181 } 182 PowerUpCounter_--; 183 this->changeClothes(); 184 fireball->destroyLater(); 185 } 134 186 135 187 //Purpose is that if player hits the flag, he should walk into the castle at the end of the level. For that we use SOBCastlestone … … 137 189 flagstone->hasCollided_ = true; 138 190 reachedLvlEndState_ = 1; 139 SOB* SOBGame = orxonox_cast<SOB*>(getGametype()); 191 140 192 SOBGame->setDone(true); 141 193 SOBGame->addPoints(flagstone->getPoints()); … … 159 211 } 160 212 213 //Function to spawn the Fireball 214 void SOBFigure::spawnFireball() { 215 SOBCenterpoint* center_ = ((SOB*)getGametype())->center_; 216 217 SOBFireball* ball = new SOBFireball(center_->getContext()); 218 Vector3 spawnpos = this->getWorldPosition(); 219 spawnpos.z += 0; 220 221 if (ball != nullptr && center_ != nullptr) 222 { 223 ball->addTemplate("fireball"); 224 bool direction = ((this->getWorldOrientation().getRoll().valueRadians())>-1.6&&(this->getWorldOrientation().getRoll().valueRadians()<1.6)); 225 ball->setDirection(direction); 226 if(direction) 227 { 228 spawnpos.x+=10; 229 } 230 else 231 { 232 spawnpos.x-=10; 233 } 234 ball->setPosition(spawnpos); 235 236 } 237 } 238 161 239 //For those of you who don't have an idea: the tick function is called about 50 times/sec 162 240 void SOBFigure::tick(float dt) … … 166 244 167 245 bool inputAllowed = true; 246 //SOB* SOBGame = orxonox_cast<SOB*>(getGametype()); 168 247 169 248 //the particle spawner that generates the fire from the backpack when pressed … … 174 253 particlespawner_ = object; 175 254 } 176 } 255 256 } 257 177 258 178 259 … … 190 271 //if input blocked, then cancel every movement operation 191 272 if (!inputAllowed) { 192 moveUpPressed_ = false;193 moveDownPressed_ = false;194 moveLeftPressed_ = false;195 moveRightPressed_ = false;273 moveUpPressed_ = false; 274 moveDownPressed_ = false; 275 moveLeftPressed_ = false; 276 moveRightPressed_ = false; 196 277 } 197 278 … … 204 285 if (hasLocalController()) 205 286 { 287 SOB* SOBGame = orxonox_cast<SOB*>(getGametype()); 206 288 Vector3 velocity = getVelocity(); 207 289 Vector3 position = getPosition(); … … 212 294 if (position.z < -100) { 213 295 dead_ = true; 214 SOB* SOBGame = orxonox_cast<SOB*>(getGametype());215 296 SOBGame->setDone(true); 216 297 } … … 221 302 velocity.z = 0; 222 303 setVelocity(velocity); 223 SOB* SOBGame = orxonox_cast<SOB*>(getGametype());304 224 305 if (firePressed_) 225 306 SOBGame->restart(); … … 242 323 else 243 324 particlespawner_->setVisible(false); 244 325 245 326 246 327 //If player hits space and collides against an object under him then jump 247 if (inputAllowed && firePressed_ && isColliding_ && (collDisZ_ >= 7.75 && collDisZ_ <+ 8.25)) {248 gravityAcceleration_ = 100.0;249 velocity.z = 1 10;328 if (inputAllowed && firePressed_ && isColliding_ && (collDisZ_ >= 0 && collDisZ_ <+ 10)) { 329 gravityAcceleration_ = 350; 330 velocity.z = 175; 250 331 } 251 332 … … 274 355 } 275 356 357 //If moveUp pressed, fire a fireball 358 if(moveUpPressed_ && (PowerUpCounter_ >= FireballPower) && fireallowed_) 359 { 360 spawnFireball(); 361 fireallowed_ = false; 362 firecooldown_ = 0; 363 } 364 365 //Increase the firecooldown 366 if(firecooldown_> 0.5) 367 { 368 fireallowed_ = true; 369 } 370 if(!fireallowed_) 371 { 372 firecooldown_ += dt; 373 } 276 374 277 375 //Again another EndOfLevel behavior … … 283 381 velocity.x = 0; 284 382 velocity.y = 20; 383 setOrientation(Vector3::UNIT_Z, Degree(90)); 285 384 } 286 385 if (reachedLvlEndState_ == 4) { 386 //Highscore 387 if (Highscore::exists()){ 388 int score = SOBGame->getPoints(); 389 if(score > Highscore::getInstance().getHighestScoreOfGame("Super Orxo Bros.")) 390 Highscore::getInstance().storeHighscore("Super Orxo Bros.",score); 391 SOBGame->newHighscore=1; 392 393 } 287 394 lvlEnded_ = true; 288 395 dead_ = true; … … 307 414 } 308 415 309 310 311 312 } 313 314 416 } 315 417 316 418 // Reset key variables 317 moveUpPressed_ = false;318 moveDownPressed_ = false;319 moveLeftPressed_ = false;320 moveRightPressed_ = false;419 moveUpPressed_ = false; 420 moveDownPressed_ = false; 421 moveLeftPressed_ = false; 422 moveRightPressed_ = false; 321 423 322 424 isColliding_ = false; … … 364 466 365 467 366 } 468 469 // PRE: name is an existing name of a material. Example orxo_material for orxo_material.material in data_extern/materials 470 // !!! PowerUpCounter_ has to be modified before changing the clothes!!! 471 // POST: clothes of body of player are changed to name 472 void SOBFigure::changeClothes(){ 473 // clothes: white (basic), red (one PowerUp), orange (Fireball enabled) 474 std::string clothes[] = {"orxo_material", "orxo_material_gross", "orxo_material_fire"}; 475 476 std::set<WorldEntity*> attachedObjects = this->getAttachedObjects(); 477 std::set<WorldEntity*>::iterator it; 478 for (it = attachedObjects.begin(); it != attachedObjects.end(); ++it) 479 { 480 Model* FiguresModel = orxonox_cast<Model*>(*it); 481 if (FiguresModel != nullptr) 482 { 483 FiguresModel->setSubMaterial(clothes[PowerUpCounter_] , 4); // 4 is the body 484 } 485 } 486 } 487 // PRE: 488 // POST: Player jumps out of the game, game is finished and can be restarted. 489 void SOBFigure::die(){ 490 Vector3 vel = getVelocity(); 491 vel.y = -80; 492 vel.z = 200; 493 setVelocity(vel); 494 predead_= true; 495 SOB* SOBGame = orxonox_cast<SOB*>(getGametype()); 496 SOBGame->setDone(true); 497 } 498 499 } -
code/branches/Presentation_HS17/src/modules/superorxobros/SOBFigure.h
r11418 r11678 46 46 virtual void boost(bool boost) override; 47 47 virtual bool collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint) override; 48 void changeClothes(); 49 void spawnFireball(); 50 void die(); 48 51 49 52 bool dead_; … … 54 57 55 58 //Soooo many declarations 56 bool gotPowerUp_; 59 bool fireallowed_; 60 57 61 bool moveUpPressed_; 58 62 bool moveDownPressed_; … … 63 67 float timeSinceLastFire_; 64 68 float lastSpeed_z; 69 float firecooldown_; 65 70 SOBCenterpoint* sobcenterpoint; 66 71 float pitch_; 67 72 bool isColliding_; 68 73 WorldEntity* particlespawner_; 74 int PowerUpCounter_; 75 int maxPowerUp_; 76 int FireballPower; 69 77 int sgn(float x); 70 78 int reachedLvlEndState_; -
code/branches/Presentation_HS17/src/modules/superorxobros/SOBFlagstone.h
r11416 r11678 29 29 /** 30 30 @file SOBFlagstone.h 31 @brief Declaration of the SOBFlagstone class. This class is used for the flag - for everz 10x10x10 stone we added a flagstone with different points. The higher you touch the flag, the more points you get. 31 @brief Declaration of the SOBFlagstone class. 32 This class is used for the flag - for every 10x10x10 stone we added a flagstone with different points. The higher you touch the flag, the more points you get. 32 33 @ingroup SOB 33 34 */ -
code/branches/Presentation_HS17/src/modules/superorxobros/SOBGumba.cc
r11416 r11678 60 60 changeAllowed_ = true; 61 61 changedOn_ = 0.0; 62 creator_ = nullptr; 63 maxLifetime_ = 10; 64 lifetime_ = 0; 62 65 63 66 } … … 91 94 } 92 95 96 void SOBGumba::setDirection(const bool direction) 97 { 98 if(direction) 99 { 100 goesRight_=true; 101 } 102 else 103 { 104 goesRight_=false; 105 } 106 } 93 107 108 void SOBGumba::die(){ 109 Vector3 velocity = this->getVelocity(); 110 velocity.y = speed_; 111 this->setVelocity(velocity); 112 } 94 113 95 114 void SOBGumba::tick(float dt) … … 100 119 changedOn_+= dt; 101 120 // After a collision, we don't listen for collisions for 200ms - that's because one wall can cause several collisions! 102 if (changedOn_> 0. 200) {121 if (changedOn_> 0.400) { 103 122 changeAllowed_ = true; 104 123 changedOn_ = 0.0; … … 106 125 } 107 126 } 108 127 109 128 110 129 int dir = 1; … … 113 132 114 133 Vector3 velocity = getVelocity(); 134 if(velocity.z > -1 && velocity.z < 1) 135 { 136 velocity.x = dir*speed_; 137 } 138 115 139 velocity.z -= gravityAcceleration_*dt; 116 velocity.x = dir*speed_;117 140 setVelocity(velocity); 118 141 119 142 lastPos_ = getPosition(); 143 144 if (creator_ != nullptr) 145 { 146 lifetime_ += dt; 147 if(lifetime_>maxLifetime_) 148 { 149 150 } 151 } 152 153 if(abs(this->getPosition().z) > 1000) delete this; 154 120 155 } 121 122 123 156 } -
code/branches/Presentation_HS17/src/modules/superorxobros/SOBGumba.h
r11416 r11678 51 51 virtual void tick(float dt) override; 52 52 53 void setDirection(const bool direction); 54 void die(); 53 55 54 56 bool attachedToFigure_; … … 60 62 61 63 bool hasCollided_; 64 SOBGumbaBoss* creator_; 62 65 protected: 63 66 float gravityAcceleration_; … … 68 71 bool changeAllowed_; 69 72 float changedOn_; 73 float maxLifetime_; 74 float lifetime_; 75 70 76 71 77 }; -
code/branches/Presentation_HS17/src/modules/superorxobros/SOBPrereqs.h
r11416 r11678 76 76 class SOBHUDInfo; 77 77 class SOBGumba; 78 class SOBGumbaBoss; 78 79 class SOBFlagstone; 79 80 class SOBCastlestone; -
code/branches/Presentation_HS17/src/modules/superorxobros/SOBQBlock.cc
r11416 r11678 39 39 #include "SOBMushroom.h" 40 40 #include "SOBCoin.h" 41 #include <BulletCollision/NarrowPhaseCollision/btManifoldPoint.h> 42 41 43 42 44 namespace orxonox … … 62 64 //If you hit the QBlock, the visibility of all attached objects get inverted! Pretty easy way to create changing blocks :) 63 65 float v_z = otherObject->getVelocity().z; 64 if (!used_ && v_z > 50.0) { 66 int collDisZ_ = getPosition().z - contactPoint.getPositionWorldOnB().getZ(); 67 if (!used_ && v_z > 50.0 && collDisZ_ > 0) { 65 68 used_ = true; 66 69
Note: See TracChangeset
for help on using the changeset viewer.