Changeset 8488 for code/branches/tetris/src/modules
- Timestamp:
- May 16, 2011, 3:13:56 PM (14 years ago)
- Location:
- code/branches/tetris/src/modules/tetris
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/tetris/src/modules/tetris/Tetris.cc
r8249 r8488 90 90 if(stone != NULL) 91 91 { 92 // Get the current position of the active stone 92 93 Vector3 position = stone->getPosition(); 93 if(position.x < this->center_->getStoneSize()/2.0) 94 95 if(position.x < this->center_->getStoneSize()/2.0) //!< If the stone touches the left edge of the level 94 96 position.x = this->center_->getStoneSize()/2.0; 95 else if(position.x > (this->center_->getWidth()-0.5)*this->center_->getStoneSize()) 97 else if(position.x > (this->center_->getWidth()-0.5)*this->center_->getStoneSize()) //!< If the stone touches the right edge of the level 96 98 position.x = (this->center_->getWidth()-0.5)*this->center_->getStoneSize(); 97 98 if(position.y < this->center_->getStoneSize()/2.0) 99 100 if(!this->correctStonePos(stone)) //!< If the stone touches another stone 101 { 102 stone->setVelocity(Vector3::ZERO); 103 this->createStone(); 104 this->startStone(); 105 } 106 107 if(position.y < this->center_->getStoneSize()/2.0) //!< If the stone has reached the bottom of the level 99 108 { 100 109 position.y = this->center_->getStoneSize()/2.0; … … 222 231 /** 223 232 @brief 233 Validate the stone position. 234 @return 235 Returns whether the supplied stone is in the correct position. 236 */ 237 bool Tetris::correctStonePos(TetrisStone* stone) 238 { 239 for(std::vector<TetrisStone*>::const_iterator it = this->stones_.begin(); it != this->stones_.end(); ++it) 240 { 241 TetrisStone* currentStone = it->_Ptr(); //!< Gives access to the current stone in the list 242 Vector3 currentStonePosition = it->_Ptr()->getPosition(); //!< Saves the position of the currentStone 243 Vector3 stonePosition = stone->getPosition(); //!< Saves the position of the supplied stone 244 245 // @TODO: Use the TetrisStone member functions to check both stones for an overlap. 246 // Also make sure to correct the stone position accordingly. 247 // 248 // This case applies if the stones overlap completely 249 //if((stonePosition.x == currentStonePosition.x) && (stonePosition.y == currentStonePosition.y)) 250 // This case applies if the stones overlap partially vertically 251 //if(stonePosition.y - stone->getHeight()/2 < currentStonePosition.y + currentStone->getHeight()/2) 252 253 254 } 255 } 256 257 /** 258 @brief 224 259 Get the player. 225 260 @return -
code/branches/tetris/src/modules/tetris/Tetris.h
r8249 r8488 80 80 void createStone(void); 81 81 void cleanup(void); //!< Cleans up the Gametype by destroying the ball and the bats. 82 bool correctStonePos(TetrisStone* stone); //!< Check whether the supplied stone is in an allowed position 82 83 83 84 PlayerInfo* player_;
Note: See TracChangeset
for help on using the changeset viewer.