Changeset 10166 for code/branches/surfaceraceHS14/src/modules/dodgerace2
- Timestamp:
- Dec 10, 2014, 3:40:05 PM (10 years ago)
- Location:
- code/branches/surfaceraceHS14/src/modules/dodgerace2
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/surfaceraceHS14/src/modules/dodgerace2/DodgeRace.cc
r10154 r10166 46 46 this->numberOfBots_ = 0; //sets number of default bots temporarly to 0 47 47 this->center_ = 0; 48 /* 49 this->setHUDTemplate("DodgeRaceHUD"); // !!!!!!!!!!!!!!! change later*/48 49 this->setHUDTemplate("DodgeRaceHUD"); 50 50 } 51 51 … … 53 53 { 54 54 bEndGame = false; 55 lives = 3;55 lives = 1; 56 56 level = 1; 57 57 point = 0; … … 59 59 multiplier = 1; 60 60 b_combo = false; 61 counter = 0;61 counter = 5000; 62 62 pattern = 1; 63 63 lastPosition = 0; … … 95 95 counter = counter + (currentPosition - lastPosition); 96 96 lastPosition = currentPosition; 97 98 for(int i=0; i< cubeList.size();i++) 97 point = currentPosition; 98 getPlayer()->speed = 830 - (point / 1000); 99 100 for(uint i=0; i < cubeList.size();i++) 99 101 { 100 102 if(cubeList.at(i)->getPosition().x < currentPosition-3000) … … 108 110 { 109 111 counter = 0; 110 111 112 for(int i = 0; i<6; i++) 112 113 { … … 147 148 return player; 148 149 } 149 /* 150 void DodgeRace::spawnEnemy() 151 { 152 if (getPlayer() == NULL) 153 return; 154 155 for (int i = 0; i < (3*log10(static_cast<double>(level)) + 1); i++) 156 { 157 WeakPtr<DodgeRaceEnemy> newPawn; 158 if (rand() % 42/(1 + level*level) == 0) 159 { 160 newPawn = new DodgeRaceEnemyShooter(this->center_->getContext()); 161 newPawn->addTemplate("enemyinvadershooter"); 162 } 163 else 164 { 165 newPawn = new DodgeRaceEnemy(this->center_->getContext()); 166 newPawn->addTemplate("enemyinvader"); 167 } 168 newPawn->setPlayer(player); 169 newPawn->level = level; 170 // spawn enemy at random points in front of player. 171 newPawn->setPosition(player->getPosition() + Vector3(500.f + 100 * i, 0, float(rand())/RAND_MAX * 400 - 200)); 172 } 173 } 174 */ 150 175 151 void DodgeRace::costLife() 176 152 { 177 orxout() << "CostLife" << endl; 178 endGameTimer.setTimer(3.0f, false, createExecutor(createFunctor(&DodgeRace::end, this))); 179 180 multiplier = 1; 153 //endGameTimer.setTimer(8.0f, false, createExecutor(createFunctor(&DodgeRace::end, this))); 154 lives = 0; 181 155 }; 182 156 … … 193 167 void DodgeRace::start() 194 168 { 195 orxout() << "start function called." << endl;169 orxout() << "start" << endl; 196 170 init(); 171 for(uint i=0; i< cubeList.size();i++) 172 { 173 cubeList.at(i)->destroy(); 174 cubeList.erase(cubeList.begin()+i); 175 176 } 177 cubeList.clear(); 178 // Set variable to temporarily force the player to spawn. 179 this->bForceSpawn_ = false; 180 181 if (this->center_ == NULL) // abandon mission! 182 { 183 orxout(internal_error) << "DodgeRace: No Centerpoint specified." << endl; 184 GSLevel::startMainMenu(); 185 return; 186 } 187 // Call start for the parent class. 188 Deathmatch::start(); 189 } 190 191 void DodgeRace::playerPreSpawn(PlayerInfo* player) 192 { 193 if(lives <= 0) 194 { 195 this->end(); 196 } 197 198 // Reset all the cubes 199 /* 200 orxout() << "prespawn" << endl; 201 init(); 197 202 for(int i=0; i< cubeList.size();i++) 198 203 { 199 204 cubeList.at(i)->destroy(); 200 205 cubeList.erase(cubeList.begin()+i); 201 202 206 } 203 cubeList.clear(); 204 // Set variable to temporarily force the player to spawn. 205 this->bForceSpawn_ = true; 206 207 if (this->center_ == NULL) // abandon mission! 208 { 209 orxout(internal_error) << "DodgeRace: No Centerpoint specified." << endl; 210 GSLevel::startMainMenu(); 211 return; 212 } 213 // Call start for the parent class. 214 Deathmatch::start(); 215 } 207 cubeList.clear(); 208 lives = 1; 209 point = 0; 210 lastPosition = 0; 211 */ 212 } 213 216 214 void DodgeRace::addPoints(int numPoints) 217 215 { -
code/branches/surfaceraceHS14/src/modules/dodgerace2/DodgeRace.h
r10154 r10166 77 77 virtual void tick(float dt); 78 78 79 virtual void playerPreSpawn(PlayerInfo* player); 80 79 81 void levelUp(); 80 82 -
code/branches/surfaceraceHS14/src/modules/dodgerace2/DodgeRaceHUDinfo.cc
r10124 r10166 41 41 42 42 this->DodgeRaceGame = 0; 43 this->bShowLives_ = false; 44 this->bShowLevel_ = false; 45 this->bShowPoints_ = false; 46 this->bShowMultiplier_ = false; 43 this->bShowPoints_ = true; 47 44 } 48 /* 45 49 46 void DodgeRaceHUDinfo::XMLPort(Element& xmlelement, XMLPort::Mode mode) 50 47 { 51 48 SUPER(DodgeRaceHUDinfo, XMLPort, xmlelement, mode); 52 49 53 XMLPortParam(DodgeRaceHUDinfo, "showlives", setShowLives, getShowLives, xmlelement, mode).defaultValues(false); 54 XMLPortParam(DodgeRaceHUDinfo, "showPoints", setShowPoints, getShowPoints, xmlelement, mode).defaultValues(false); 55 XMLPortParam(DodgeRaceHUDinfo, "showLevel", setShowLevel, getShowLevel, xmlelement, mode).defaultValues(false); 56 XMLPortParam(DodgeRaceHUDinfo, "showMultiplier", setShowMultiplier, getShowMultiplier, xmlelement, mode).defaultValues(false); 50 XMLPortParam(DodgeRaceHUDinfo,"showPoints", setShowPoints, getShowPoints, xmlelement, mode).defaultValues(false); 57 51 } 58 52 … … 61 55 SUPER(DodgeRaceHUDinfo, tick, dt); 62 56 63 if (this->DodgeRaceGame) 64 { 65 if (this->bShowLives_) 66 { 67 const std::string& lives = multi_cast<std::string>(this->DodgeRaceGame->getLives()); 68 this->setCaption(lives); 69 } 70 else if(this->bShowLevel_) 71 { 72 const std::string& Level = multi_cast<std::string>(this->DodgeRaceGame->getLevel()); 73 if (this->DodgeRaceGame->lives <= 0) 74 { 75 setPosition(Vector2(0.1, 0.65)); 76 this->setCaption("Game ends in 30 seconds.\nPress (e)xit / (q)uit to go to the main menu.\nTo restart fly out of the screen!"); 77 setTextSize(0.05); 78 this->DodgeRaceGame->bEndGame = true; 79 } 80 else if (this->DodgeRaceGame->bShowLevel) 81 { 82 setTextSize(0.1); 83 setPosition(Vector2(0.3, 0.55)); 84 std::stringstream sstm; 85 sstm << "Level " << Level; 86 this->setCaption(sstm.str()); // + level 87 } 88 else 89 { 90 setTextSize(0.04); 91 setPosition(Vector2(0.14, 0.055)); 92 this->setCaption(Level); 93 } 94 } 95 else if(this->bShowPoints_) 96 { 97 const std::string& points = multi_cast<std::string>(this->DodgeRaceGame->getPoints()); 98 if (this->DodgeRaceGame->lives <= 0) 99 { 100 setTextSize(0.2); 101 setPosition(Vector2(0.1, 0.25)); 102 this->setCaption("Final score:\n" + points); 103 this->setColour(ColourValue(1, 0, 0, 1)); 104 } 105 else 106 { 107 setTextSize(0.04); 108 setPosition(Vector2(0.14, 0.1)); 109 this->setColour(ColourValue(1, 1, 1, 1)); 110 this->setCaption(points); 111 } 112 } 113 else if(this->bShowMultiplier_) 114 { 115 int mult = this->DodgeRaceGame->getMultiplier(); 116 const std::string& Multiplier = "X " + multi_cast<std::string>(mult); 117 this->setCaption(Multiplier); 118 this->setColour(ColourValue(1, 0, 0, clamp(float(mult * 0.1), 0.0f, 1.0f))); 119 this->setTextSize(clamp(float(mult * 0.1), 0.0f, 1.0f) * 0.01f + 0.04f); 120 } 121 } 57 58 if(this->bShowPoints_) 59 { 60 const std::string& points = multi_cast<std::string>(this->DodgeRaceGame->getPoints()); 61 if (this->DodgeRaceGame->lives <= 0) 62 { 63 setTextSize(0.2); 64 setPosition(Vector2(0.1, 0.02)); 65 this->setCaption("Final score:\n" + points); 66 this->setColour(ColourValue(1, 0, 0, 1)); 67 } 68 else 69 { 70 setTextSize(0.04); 71 setPosition(Vector2(0.14, 0.02)); 72 this->setColour(ColourValue(1, 1, 1, 1)); 73 this->setCaption(points); 74 } 75 } 122 76 } 123 77 … … 134 88 this->DodgeRaceGame = 0; 135 89 } 136 } */90 } 137 91 } -
code/branches/surfaceraceHS14/src/modules/dodgerace2/DodgeRaceHUDinfo.h
r10124 r10166 44 44 DodgeRaceHUDinfo(Context* context); 45 45 46 // virtual void tick(float dt); 47 // virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 48 //virtual void changedOwner(); 49 50 inline void setShowLives(bool value) 51 { this->bShowLives_ = value; } 52 inline bool getShowLives() const 53 { return this->bShowLives_; } 54 55 inline void setShowLevel(bool value) 56 { this->bShowLevel_ = value; } 57 inline bool getShowLevel() const 58 { return this->bShowLevel_; } 46 virtual void tick(float dt); 47 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 48 virtual void changedOwner(); 59 49 60 50 inline void setShowPoints(bool value) … … 63 53 { return this->bShowPoints_; } 64 54 65 inline void setShowMultiplier(bool value)66 { this->bShowMultiplier_ = value; }67 inline bool getShowMultiplier() const68 { return this->bShowMultiplier_; }69 70 55 71 56 private: 72 57 DodgeRace* DodgeRaceGame; 73 bool bShowLives_;74 bool bShowLevel_;75 58 bool bShowPoints_; 76 bool bShowMultiplier_;77 59 }; 78 60 } -
code/branches/surfaceraceHS14/src/modules/dodgerace2/DodgeRaceShip.cc
r10154 r10166 42 42 RegisterObject(DodgeRaceShip); 43 43 44 speed = 8 00;44 speed = 830; 45 45 isFireing = false; 46 46 damping = 10; … … 68 68 { 69 69 float dist_y = velocity.y * dt; 70 float dist_x = velocity.x * dt;70 //float dist_x = velocity.x * dt; 71 71 if(dist_y + posforeward > -42*3 && dist_y + posforeward < 42*6) 72 72 posforeward += dist_y; … … 75 75 velocity.y = 0; 76 76 // restart if game ended 77 77 /* 78 78 if (getGame()) 79 79 if (getGame()->bEndGame) … … 83 83 }*/ 84 84 } 85 /* 86 if (pos.z + dist_x > 42*2.5 || pos.z + dist_x < -42*3) 87 { 88 velocity.x = 0; 89 } 90 */ 85 91 86 pos += Vector3(1000 + velocity.y, 0, velocity.x) * dt; 92 }93 94 // shoot!95 if (isFireing)96 {97 //pos += Vector3(900, 0, 0) * dt;98 //ControllableEntity::fire(0);99 87 } 100 88 … … 150 138 void DodgeRaceShip::boost(bool bBoost) 151 139 { 152 // isFireing= bBoost;140 //getGame()->bEndGame = bBoost; 153 141 } 154 142 155 143 inline bool DodgeRaceShip::collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint) 156 144 { 157 /*158 if (otherObject != NULL && lastEntity != otherObject)159 {160 lastEntity = otherObject;161 removeHealth(20);162 }163 */164 145 165 146 removeHealth(100);
Note: See TracChangeset
for help on using the changeset viewer.