- Timestamp:
- Nov 27, 2017, 5:00:59 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2D.cc
r11593 r11608 35 35 #include "Asteroids2DShip.h" // Necessary for getPlayer function. Do NOT include this in Header! 36 36 #include "core/CoreIncludes.h" 37 37 #include "Highscore.h" 38 38 39 39 namespace orxonox … … 44 44 { 45 45 RegisterObject(Asteroids2D); 46 this->bEndGame = false;47 46 47 bEndGame = false; 48 lives = 1; 49 level = 1; 50 point = 0; 51 bShowLevel = false; 52 multiplier = 1; 53 b_combo = false; 54 counter = 5000; 55 pattern = 1; 56 lastPosition = 0; 57 // spawn enemy every 3.5 seconds 58 //enemySpawnTimer.setTimer(3.5f, true, createExecutor(createFunctor(&Asteroids2D::spawnEnemy, this))); 59 this->numberOfBots_ = 0; //sets number of default bots temporarly to 0 60 this->center_ = nullptr; 61 this->setHUDTemplate("Asteroids2DHUD"); 62 } 63 64 void Asteroids2D::levelUp() 65 { 66 level++; 67 if (getPlayer() != nullptr) 68 { 69 for (int i = 0; i < 7; i++) 70 { 71 WeakPtr<ExplosionPart> chunk5 = new ExplosionPart(this->center_->getContext()); 72 chunk5->setPosition(Vector3(600, 0, 100.f * i - 300)); 73 chunk5->setVelocity(Vector3(1000, 0, 0)); //player->getVelocity() 74 chunk5->setScale(10); 75 chunk5->setEffect1("Orxonox/explosion2b"); 76 chunk5->setEffect2("Orxonox/smoke6"); 77 chunk5->Explode(); 78 79 } 80 } 81 addPoints(multiplier * 42); 82 multiplier *= 2; 83 toggleShowLevel(); 84 showLevelTimer.setTimer(1.0f, false, createExecutor(createFunctor(&Asteroids2D::toggleShowLevel, this))); 48 85 } 49 86 50 87 void Asteroids2D::tick(float dt) 51 88 { 52 89 53 90 SUPER(Asteroids2D, tick, dt); 54 91 } … … 66 103 } 67 104 105 void Asteroids2D::costLife() 106 { 107 //endGameTimer.setTimer(8.0f, false, createExecutor(createFunctor(&Asteroids2D::end, this))); 108 lives = 0; 109 }; 110 68 111 void Asteroids2D::start() 69 112 { 70 113 orxout() << "start" << endl; 71 114 72 115 // Set variable to temporarily force the player to spawn. 73 116 this->bForceSpawn_ = false; … … 83 126 } 84 127 128 void Asteroids2D::playerPreSpawn(PlayerInfo* player) 129 { 130 if(lives <= 0) 131 { 132 this->end(); 133 } 134 } 135 136 void Asteroids2D::addPoints(int numPoints) 137 { 138 if (!bEndGame) 139 { 140 point += numPoints * multiplier; 141 b_combo = true; 142 } 143 } 144 85 145 void Asteroids2D::end() 86 146 { … … 89 149 // It will misteriously crash the game! 90 150 // Instead startMainMenu, this won't crash. 91 orxout() << "Asteroids2D Game has ended" << endl; 151 if (Highscore::exists()){ 152 int score = this->getPoints(); 153 if(score > Highscore::getInstance().getHighestScoreOfGame("Dodge Race")) 154 Highscore::getInstance().storeHighscore("Dodge Race",score); 155 156 } 92 157 GSLevel::startMainMenu(); 93 158 }
Note: See TracChangeset
for help on using the changeset viewer.