Changeset 9868 for code/branches/invaders/src/modules/invader/Invader.cc
- Timestamp:
- Dec 3, 2013, 8:18:15 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/invaders/src/modules/invader/Invader.cc
r9866 r9868 59 59 RegisterObject(Invader); 60 60 this->center_ = 0; 61 init(); 62 this->setHUDTemplate("InvaderHUD"); 63 } 61 64 62 this->console_addEnemy = createConsoleCommand( "spawnEnemy", createExecutor( createFunctor(&Invader::spawnEnemy, this) ) ); 63 //this->context = context; 64 this->setHUDTemplate("InvaderHUD"); 65 65 void Invader::init() 66 { 67 bEndGame = false; 66 68 lives = 3; 69 // TODO: 67 70 level = 1; 68 71 point = 0; 69 72 multiplier = 1; 70 73 b_combo = false; 74 // spawn enemy every 2 seconds 71 75 enemySpawnTimer.setTimer(2.0f, true, createExecutor(createFunctor(&Invader::spawnEnemy, this))); 72 76 comboTimer.setTimer(2.5f, true, createExecutor(createFunctor(&Invader::comboControll, this))); 73 }74 75 Invader::~Invader()76 {77 77 } 78 78 … … 94 94 newPawn->setPlayer(player); 95 95 newPawn->level = level; 96 // spawn enemy at random points in front of player. 96 97 newPawn->setPosition(player->getPosition() + Vector3(500 + 100 * i, 0, float(rand())/RAND_MAX * 400 - 200)); 97 98 } … … 101 102 { 102 103 lives--; 103 multiplier = 0; 104 if (lives <= 0) end(); 104 multiplier = 1; 105 // end the game in 30 seconds. 106 if (lives <= 0) 107 enemySpawnTimer.setTimer(30.0f, false, createExecutor(createFunctor(&Invader::end, this))); 105 108 }; 106 109 … … 109 112 if (b_combo) 110 113 multiplier++; 114 // if no combo was performed before, reset multiplier 111 115 else 112 116 multiplier = 1; … … 114 118 } 115 119 116 // inject custom player controller117 /** void Invader::spawnPlayer(PlayerInfo* player)118 {119 assert(player);120 121 //player->startControl(new InvaderShip(this->center_->getContext() ) );122 }*/123 124 120 void Invader::start() 125 121 { 122 init(); 126 123 // Set variable to temporarily force the player to spawn. 127 124 this->bForceSpawn_ = true; … … 137 134 } 138 135 136 139 137 void Invader::end() 140 138 { 141 orxout() << "STOP THE GAME, CHEATER!!!" << endl; 142 // Call end for the parent class. 143 // Deathmatch::end(); 139 // DON'T CALL THIS! 140 // Deathmatch::end(); 141 // It will misteriously crash the game! 142 // Instead startMainMenu, this won't crash. 143 GSLevel::startMainMenu(); 144 144 } 145 145 }
Note: See TracChangeset
for help on using the changeset viewer.