- Timestamp:
- Nov 6, 2017, 3:32:04 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrx.cc
r11533 r11537 74 74 75 75 void FlappyOrx::updatePlayerPos(int x){ 76 76 77 if(this->tubes.size()==0||x-this->tubes.back()-tubeOffsetX>spawnDistance){ 77 78 spawnTube(); … … 82 83 levelUp(); 83 84 point++; 85 } 86 while((this->asteroids.front())->getPosition().x<x-300){ 87 MovableEntity* deleteMe = asteroids.front(); 88 asteroids.pop(); 89 deleteMe->destroy(); 84 90 } 85 91 } … … 144 150 } 145 151 152 void deleteAsteroid(MovableEntity* asteroid){ 153 //center_->getContext().getObjectList().removeElement(asteroid); 154 } 155 146 156 void FlappyOrx::createAsteroid(Circle &c){ 147 157 orxout() << "created Asteroid at x="<<c.x<<" y="<<c.y << std::endl; 158 148 159 MovableEntity* newAsteroid = new MovableEntity(this->center_->getContext()); 160 161 149 162 if(c.r<=5) 150 163 newAsteroid->addTemplate(Asteroid5[rand()%6]); … … 160 173 newAsteroid->setOrientation(Vector3::UNIT_Y, Degree(rand()%360)); 161 174 175 asteroids.push(newAsteroid); 176 177 162 178 } 163 179 … … 169 185 void FlappyOrx::costLife() 170 186 { 171 lives--; 172 multiplier = 1; 173 // end the game in 30 seconds. 174 if (lives <= 0) 175 enemySpawnTimer.setTimer(30.0f, false, createExecutor(createFunctor(&FlappyOrx::end, this))); 187 176 188 }; 177 189 … … 206 218 point += numPoints * multiplier; 207 219 b_combo = true; 220 } 221 } 222 223 void FlappyOrx::death(){ 224 if (Highscore::exists()){ 225 int score = this->getPoints(); 226 if(score > Highscore::getInstance().getHighestScoreOfGame("Orxonox Arcade")) 227 Highscore::getInstance().storeHighscore("Orxonox Arcade",score); 228 229 } 230 point = 0; 231 while (!tubes.empty()) 232 { 233 tubes.pop(); 234 } 235 while (!asteroids.empty()) 236 { 237 MovableEntity* deleteMe = asteroids.front(); 238 asteroids.pop(); 239 deleteMe->destroy(); 208 240 } 209 241 }
Note: See TracChangeset
for help on using the changeset viewer.