Changeset 9329 for code/branches/presentation2012merge
- Timestamp:
- Jul 22, 2012, 6:46:05 PM (12 years ago)
- Location:
- code/branches/presentation2012merge/src/modules/tetris
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation2012merge/src/modules/tetris/Tetris.cc
r9328 r9329 118 118 { 119 119 this->endGameCriteria_ += dt; 120 if(!this->isValidBrickPosition(this->activeBrick_ , this->activeBrick_->getPosition()))120 if(!this->isValidBrickPosition(this->activeBrick_)) 121 121 { 122 122 for (unsigned int i = 0; i < this->activeBrick_->getNumberOfStones(); i++) … … 195 195 assert(stone); 196 196 197 // we use a reverse iterator because we have to check for collisions with the topmost stones first198 for(std::list<SmartPtr<TetrisStone> >::const_ reverse_iterator it = this->stones_.rbegin(); it != this->stones_.rend(); ++it)197 // check for collisions with all stones 198 for(std::list<SmartPtr<TetrisStone> >::const_iterator it = this->stones_.begin(); it != this->stones_.end(); ++it) 199 199 { 200 200 //Vector3 currentStonePosition = rotateVector((*it)->getPosition(), this->activeBrick_->getRotationCount()); … … 231 231 * 232 232 */ 233 bool Tetris::isValidBrickPosition(TetrisBrick* brick , const Vector3& position)233 bool Tetris::isValidBrickPosition(TetrisBrick* brick) 234 234 { 235 235 assert(brick); 236 236 237 const Vector3& brickPosition = this->activeBrick_->getPosition(); 238 239 // check all stones in the brick 237 240 for (unsigned int i = 0; i < brick->getNumberOfStones(); i++ ) 238 241 { 239 242 TetrisStone* stone = brick->getStone(i); 240 Vector3 stonePosition = rotateVector(stone->getPosition(), brick->getRotationCount()); 241 if(! this->isValidStonePosition(stone, position + stonePosition) ) 243 const Vector3& stonePosition = rotateVector(stone->getPosition(), brick->getRotationCount()); 244 if(! this->isValidStonePosition(stone, brickPosition + stonePosition) ) 245 { 246 // recurse because all stones have to checked again after the brick was re-positioned 247 this->isValidBrickPosition(brick); 242 248 return false; 249 } 243 250 } 244 251 return true; -
code/branches/presentation2012merge/src/modules/tetris/Tetris.h
r9328 r9329 84 84 void cleanup(void); //!< Cleans up the Gametype by destroying the ball and the bats. 85 85 bool isValidStonePosition(TetrisStone* stone, const Vector3& position); 86 bool isValidBrickPosition(TetrisBrick* brick , const Vector3& position);86 bool isValidBrickPosition(TetrisBrick* brick); 87 87 void findFullRows(void); 88 88 void clearRow(unsigned int row);
Note: See TracChangeset
for help on using the changeset viewer.