- Timestamp:
- Feb 11, 2018, 4:49:56 PM (7 years ago)
- Location:
- code/branches/Presentation_HS17_merge/src/modules/dodgerace
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/Presentation_HS17_merge/src/modules/dodgerace/DodgeRace.cc
r11716 r11729 37 37 #include "core/CoreIncludes.h" 38 38 #include "Highscore.h" 39 #include "infos/PlayerInfo.h" 39 40 40 41 namespace orxonox … … 90 91 void DodgeRace::tick(float dt) 91 92 { 92 if (getPlayer() != nullptr) 93 { 94 currentPosition = getPlayer()->getWorldPosition().x; 93 DodgeRaceShip* player = this->getPlayer(); 94 if (player != nullptr) 95 { 96 currentPosition = player->getWorldPosition().x; 95 97 counter = counter + (currentPosition - lastPosition); 96 98 lastPosition = currentPosition; 97 99 point = (int) currentPosition; 98 getPlayer()->speed = 830.0f - (point / 1000);100 player->speed = 830.0f - (point / 1000); 99 101 100 102 for(unsigned int i=0; i < cubeList.size();i++) … … 123 125 } 124 126 125 cube->setPosition( getPlayer()->getWorldPosition() + Vector3(5000.0f, 0.0f, -3600.0f + (i*1200)));127 cube->setPosition(player->getWorldPosition() + Vector3(5000.0f, 0.0f, -3600.0f + (i*1200))); 126 128 //stEntity->setScale3D(50,50,50); 127 129 } … … 139 141 DodgeRaceShip* DodgeRace::getPlayer() 140 142 { 141 if (player == nullptr) 142 { 143 for (DodgeRaceShip* ship : ObjectList<DodgeRaceShip>()) 144 { 145 player = ship; 146 } 147 } 148 return player; 143 for (DodgeRaceShip* ship : ObjectList<DodgeRaceShip>()) 144 { 145 return ship; 146 } 147 return nullptr; 149 148 } 150 149 … … 190 189 void DodgeRace::playerPreSpawn(PlayerInfo* player) 191 190 { 191 this->playerInfo_ = player; 192 192 if(lives <= 0) 193 193 { … … 228 228 { 229 229 int score = this->getPoints(); 230 Highscore::getInstance().storeScore("Dodge Race", score, this-> getPlayer()->getPlayer());230 Highscore::getInstance().storeScore("Dodge Race", score, this->playerInfo_); 231 231 } 232 232 GSLevel::startMainMenu(); -
code/branches/Presentation_HS17_merge/src/modules/dodgerace/DodgeRace.h
r11071 r11729 103 103 104 104 DodgeRaceShip* getPlayer(); 105 WeakPtr< DodgeRaceShip> player;105 WeakPtr<PlayerInfo> playerInfo_; 106 106 std::vector<DodgeRaceCube*> cubeList; 107 107 void toggleShowLevel(){bShowLevel = !bShowLevel;}
Note: See TracChangeset
for help on using the changeset viewer.