Changeset 10236 for code/branches
- Timestamp:
- Feb 1, 2015, 3:56:21 PM (10 years ago)
- Location:
- code/branches/surfaceraceHS14/src/modules/dodgerace
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/surfaceraceHS14/src/modules/dodgerace/DodgeRace.cc
r10235 r10236 88 88 void DodgeRace::tick(float dt) 89 89 { 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 case 2:cube->addTemplate("DodgeRaceCube02");121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 90 if (getPlayer() != NULL) 91 { 92 //WeakPtr<DodgeRaceShip> ship = getPlayer(); 93 94 currentPosition = getPlayer()->getWorldPosition().x; 95 counter = counter + (currentPosition - lastPosition); 96 lastPosition = currentPosition; 97 point = (int) currentPosition; 98 getPlayer()->speed = 830.0f - (point / 1000); 99 100 for(unsigned int i=0; i < cubeList.size();i++) 101 { 102 if(cubeList.at(i)->getPosition().x < currentPosition-3000) 103 { 104 cubeList.at(i)->destroy(); 105 cubeList.erase(cubeList.begin()+i); 106 } 107 } 108 109 if(counter >= 3000) 110 { 111 counter = 0; 112 for(int i = 0; i<6; i++) 113 { 114 WeakPtr<DodgeRaceCube> cube = new DodgeRaceCube(this->center_->getContext()); 115 cubeList.push_back(cube); 116 switch(pattern) 117 { 118 case 1: cube->addTemplate("DodgeRaceCube01"); 119 break; 120 case 2: cube->addTemplate("DodgeRaceCube02"); 121 break; 122 123 } 124 125 cube->setPosition(getPlayer()->getWorldPosition() + Vector3(5000.0f, 0.0f, -3600.0f + (i*1200))); 126 //stEntity->setScale3D(50,50,50); 127 } 128 129 130 pattern %= 2; 131 pattern ++; 132 133 } 134 135 } 136 SUPER(DodgeRace, tick, dt); 137 137 } 138 138 … … 143 143 for (ObjectList<DodgeRaceShip>::iterator it = ObjectList<DodgeRaceShip>::begin(); it != ObjectList<DodgeRaceShip>::end(); ++it) 144 144 { 145 145 player = *it; 146 146 } 147 147 } … … 151 151 void DodgeRace::costLife() 152 152 { 153 154 153 //endGameTimer.setTimer(8.0f, false, createExecutor(createFunctor(&DodgeRace::end, this))); 154 lives = 0; 155 155 }; 156 156 … … 167 167 void DodgeRace::start() 168 168 { 169 169 orxout() << "start" << endl; 170 170 init(); 171 172 173 174 175 176 171 for(unsigned int i=0; i< cubeList.size();i++) 172 { 173 cubeList.at(i)->destroy(); 174 cubeList.erase(cubeList.begin()+i); 175 176 } 177 177 cubeList.clear(); 178 178 // Set variable to temporarily force the player to spawn. … … 189 189 } 190 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 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(); 202 for(int i=0; i< cubeList.size();i++) 203 { 204 cubeList.at(i)->destroy(); 205 cubeList.erase(cubeList.begin()+i); 206 } 207 cubeList.clear(); 208 208 lives = 1; 209 209 point = 0; 210 210 lastPosition = 0; 211 211 */ 212 212 } 213 213 214 214 void DodgeRace::addPoints(int numPoints) -
code/branches/surfaceraceHS14/src/modules/dodgerace/DodgeRace.h
r10235 r10236 39 39 40 40 #include "DodgeRaceCenterPoint.h" // Necessary for WeakPointer?? 41 //#include "DodgeRaceShip.h" 41 //#include "DodgeRaceShip.h" DO NOT include in Header. Will cause forward declaration issues 42 42 43 43 //#include "DodgeRaceHUDinfo.h" … … 118 118 119 119 Timer enemySpawnTimer; 120 121 120 Timer comboTimer; 121 Timer showLevelTimer; 122 122 123 123 -
code/branches/surfaceraceHS14/src/modules/dodgerace/DodgeRaceCube.cc
r10232 r10236 36 36 namespace orxonox 37 37 { 38 38 RegisterClass(DodgeRaceCube); 39 39 40 41 42 43 40 DodgeRaceCube::DodgeRaceCube(Context* context) : MovableEntity(context) 41 { 42 RegisterObject(DodgeRaceCube); 43 } 44 44 45 45 -
code/branches/surfaceraceHS14/src/modules/dodgerace/DodgeRaceHUDinfo.cc
r10232 r10236 56 56 57 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 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 } 76 76 } 77 77 -
code/branches/surfaceraceHS14/src/modules/dodgerace/DodgeRaceShip.cc
r10232 r10236 101 101 if(pos.y != 0) 102 102 { 103 103 pos.y = 0; 104 104 } 105 105 … … 126 126 void DodgeRaceShip::moveFrontBack(const Vector2& value) 127 127 { 128 129 128 //lastTimeFront = 0; 129 //desiredVelocity.y = value.y * speed * 42; 130 130 131 131 } … … 133 133 void DodgeRaceShip::moveRightLeft(const Vector2& value) 134 134 { 135 136 135 lastTimeLeft = 0; 136 desiredVelocity.x = value.x * speed; 137 137 } 138 138 void DodgeRaceShip::boost(bool bBoost) … … 144 144 { 145 145 146 147 146 removeHealth(100); 147 this->death(); 148 148 return false; 149 149 } … … 155 155 for (ObjectList<DodgeRace>::iterator it = ObjectList<DodgeRace>::begin(); it != ObjectList<DodgeRace>::end(); ++it) 156 156 { 157 157 game = *it; 158 158 } 159 159 } -
code/branches/surfaceraceHS14/src/modules/dodgerace/DodgeRaceShip.h
r10234 r10236 57 57 58 58 // overwrite for 2d movement 59 60 59 virtual void moveFrontBack(const Vector2& value); 60 virtual void moveRightLeft(const Vector2& value); 61 61 62 63 62 // Starts or stops fireing 63 virtual void boost(bool bBoost); 64 64 65 66 67 65 //no rotation! 66 virtual void rotateYaw(const Vector2& value){}; 67 virtual void rotatePitch(const Vector2& value){}; 68 68 69 70 69 //return to main menu if game has ended. 70 virtual void rotateRoll(const Vector2& value){if (getGame()) if (getGame()->bEndGame) getGame()->end();}; 71 71 72 72 virtual void updateLevel(); 73 73 74 74 float speed, damping, posforeward; … … 88 88 struct Velocity 89 89 { 90 91 90 float x; 91 float y; 92 92 } velocity, desiredVelocity; 93 93
Note: See TracChangeset
for help on using the changeset viewer.