Changeset 10100 for code/branches/minigame4DHS14
- Timestamp:
- Oct 29, 2014, 1:21:53 PM (10 years ago)
- Location:
- code/branches/minigame4DHS14
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/minigame4DHS14/data/levels/4Dtest.oxw
r10096 r10100 60 60 </Mini4DgameCenterpoint> 61 61 62 63 <!-- Blinking Slot Selector --> 62 <!-- Blinking Slot Selector 64 63 <BlinkingBillboard position="0,0,0" frequency=0.6 amplitude=0.4 material="Flares/lensflare" colour="1,1,0.05"> 65 64 <events> … … 75 74 </events> 76 75 </BlinkingBillboard> 77 76 --> 78 77 <!-- Planet in the middle 79 78 <Planet -
code/branches/minigame4DHS14/src/modules/mini4Dgame/Mini4Dgame.cc
r10097 r10100 62 62 RegisterObject(Mini4Dgame); 63 63 64 this->center_ = 0; 65 this->player_[0] = NULL; 66 this->player_[1] = NULL; 64 this->center_ = NULL; 65 //TODO: player Null setzen 67 66 } 68 67 … … 134 133 } 135 134 136 ---------------------------------------------------------------------------------------------------------------------------------137 135 138 136 /** … … 142 140 void Mini4Dgame::spawnPlayersIfRequested() 143 141 { 144 // Spawn a human player.142 // first spawn human players to assign always the left bat to the player in singleplayer 145 143 for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it) 146 144 if (it->first->isHumanPlayer() && (it->first->isReadyToSpawn() || this->bForceSpawn_)) 147 145 this->spawnPlayer(it->first); 148 } 149 150 bool Tetris::playerLeft(PlayerInfo* player) 151 { 152 bool left = Gametype::playerLeft(player); 153 if(player && player->isHumanPlayer()) 154 { 155 if(this->activeBrick_ != NULL) 156 { 157 this->player_->stopControl(); 158 } 159 this->cleanup(); 160 } 161 return left; 146 // now spawn bots 147 for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it) 148 if (!it->first->isHumanPlayer() && (it->first->isReadyToSpawn() || this->bForceSpawn_)) 149 this->spawnPlayer(it->first); 162 150 } 163 151 … … 168 156 The player to be spawned. 169 157 */ 170 void Tetris::spawnPlayer(PlayerInfo* player)158 void Mini4Dgame::spawnPlayer(PlayerInfo* player) 171 159 { 172 160 assert(player); 173 161 174 if( this->player_ == NULL)162 if(false)//this->player_ == NULL) 175 163 { 176 this->player_ = player;164 //this->player_ = player; 177 165 this->players_[player].state_ = PlayerState::Alive; 178 166 } 179 }180 181 182 183 void Tetris::startBrick(void)184 {185 if(this->player_ == NULL)186 return;187 188 unsigned int cameraIndex = 0;189 if(this->activeBrick_ != NULL)190 {191 // Get camera settings192 cameraIndex = this->activeBrick_->getCurrentCameraIndex();193 this->player_->stopControl();194 // destroy old active brick195 this->activeBrick_->destroy();196 }197 198 // Make the last brick to be created the active brick.199 this->activeBrick_ = this->futureBrick_;200 this->futureBrick_ = 0;201 202 // set its position203 this->player_->startControl(this->activeBrick_);204 float xPos = (this->center_->getWidth()/2 + ((this->center_->getWidth() % 2)*2-1)/2.0f)*this->center_->getStoneSize();205 float yPos = (this->center_->getHeight()-0.5f)*this->center_->getStoneSize();206 this->activeBrick_->setPosition(xPos, yPos, 0.0f);207 this->activeBrick_->setVelocity(0.0f, -this->center_->getStoneSpeed(), 0.0f);208 this->activeBrick_->setCameraPosition(cameraIndex);209 210 // create a new future brick211 this->createBrick();212 213 // check if the new brick is in a valid position, otherwise end the game214 if (!this->isValidBrickPosition(this->activeBrick_))215 this->end();216 }217 218 void Tetris::createBrick(void) //TODO: random rotation offset between 0 and 3 (times 90°)219 {220 // create new futureBrick_221 this->futureBrick_ = new TetrisBrick(this->center_->getContext());222 223 224 // Apply the stone template to the stone.225 this->futureBrick_->addTemplate(this->center_->getBrickTemplate());226 227 // Attach the brick to the Centerpoint and set the position of the brick to be at the left side.228 this->center_->attach(this->futureBrick_);229 float xPos = (this->center_->getWidth()*1.6f + ((this->center_->getWidth() % 2)*2-1)/2.0f)*this->center_->getStoneSize();230 float yPos = (this->center_->getHeight()-5.1f)*this->center_->getStoneSize();231 232 this->futureBrick_->setPosition(xPos, yPos, 0.0f);233 this->futureBrick_->setGame(this);234 167 } 235 168 … … 241 174 Returns a pointer to the player. If there is no player, NULL is returned. 242 175 */ 243 PlayerInfo* Tetris::getPlayer(void) const 176 //TODO: colors 177 PlayerInfo* Mini4Dgame::getPlayer(int color) const 244 178 { 245 return this->player_; 179 return players[color]; 180 //for(int i=0;i<NUMBEROFPLAYERS;i++) 181 //if(color == this->mini4DgamePlayers[i].color) 182 //return this->mini4DgamePlayers[i].info; 246 183 } 247 184 248 /*TetrisCenterpoint* Tetris::getCenterpoint(void) const249 {250 return this->center_;251 }*/252 253 /**254 @brief Set the TetrisCenterpoint (the playing field).255 @param center A pointer to the TetrisCenterpoint to be set.256 */257 void Tetris::setCenterpoint(TetrisCenterpoint* center)258 {259 this->center_ = center;260 }261 262 /**263 @brief Check each row if it is full. Removes all full rows. Update264 @brief Manages score.265 */266 void Tetris::findFullRows()267 {268 unsigned int correctPosition = 0;269 unsigned int stonesPerRow = 0;270 for (unsigned int row = 0; row < this->center_->getHeight(); row++)271 {272 stonesPerRow = 0;273 for(std::list<SmartPtr<TetrisStone> >::iterator it = this->stones_.begin(); it != this->stones_.end(); )274 {275 std::list<SmartPtr<TetrisStone> >::iterator it_temp = it++;276 correctPosition = static_cast<unsigned int>(((*it_temp)->getPosition().y - 5)/this->center_->getStoneSize());277 if(correctPosition == row)278 {279 stonesPerRow++;280 if(stonesPerRow == this->center_->getWidth())281 {282 clearRow(row);283 row--; //the row counter has to be decreased in order to detect multiple rows!284 this->playerScored(this->player_);// add points285 //increase the stone's speed286 this->center_->setStoneSpeed(this->center_->getStoneSpeed()+1.0f);287 }288 }289 }290 }291 }292 293 void Tetris::clearRow(unsigned int row)294 {// clear the full row295 for(std::list<SmartPtr<TetrisStone> >::iterator it = this->stones_.begin(); it != this->stones_.end(); )296 {297 if(static_cast<unsigned int>(((*it)->getPosition().y - 5)/this->center_->getStoneSize()) == row)298 {299 (*it)->destroy();300 this->stones_.erase(it++);301 }302 else303 ++it;304 }305 // adjust height of stones above the deleted row //TODO: check if this could be a source of a bug.306 for(std::list<SmartPtr<TetrisStone> >::iterator it = this->stones_.begin(); it != this->stones_.end(); ++it)307 {308 if(static_cast<unsigned int>(((*it)->getPosition().y - 5)/this->center_->getStoneSize()) > row)309 (*it)->setPosition((*it)->getPosition()-Vector3(0,10,0));310 }311 312 }313 314 315 185 } -
code/branches/minigame4DHS14/src/modules/mini4Dgame/Mini4Dgame.h
r10097 r10100 39 39 namespace orxonox 40 40 { 41 42 41 /** 43 42 @brief … … 56 55 57 56 virtual void spawnPlayer(PlayerInfo* player); //!< Spawns the input player. 58 virtual bool playerLeft(PlayerInfo* player);59 57 60 58 void setCenterpoint(Mini4DgameCenterpoint* center) 61 59 { this->center_ = center; } 62 60 63 PlayerInfo* getLeftPlayer() const; //!< Get the left player. 64 PlayerInfo* get RightPlayer() const; //!< Get the right player.61 //TODO: enum colors 62 PlayerInfo* getPlayer(int color) const; //!< Get the player with the specified color. 65 63 66 64 … … 74 72 void cleanup(void); //!< Cleans up the Gametype by destroying the ball and the bats. 75 73 76 PlayerInfo* player_[2];//!< The two players74 PlayerInfo* players[3]; 77 75 78 76 WeakPtr<Mini4DgameCenterpoint> center_; //!< The playing field.
Note: See TracChangeset
for help on using the changeset viewer.