- Timestamp:
- Feb 1, 2015, 3:56:21 PM (9 years ago)
- File:
-
- 1 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)
Note: See TracChangeset
for help on using the changeset viewer.