Changeset 8566 for code/branches/presentation/src/modules/tetris/Tetris.cc
- Timestamp:
- May 24, 2011, 10:12:42 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation/src/modules/tetris/Tetris.cc
r8565 r8566 106 106 } 107 107 108 std::pair<bool, TetrisStone*>Tetris::isValidMove(TetrisStone* stone, const Vector3& position)108 bool Tetris::isValidMove(TetrisStone* stone, const Vector3& position) 109 109 { 110 110 assert(stone); 111 111 112 std::pair<bool, TetrisStone*> valid = std::pair<bool, TetrisStone*>(true, NULL);113 114 112 if(position.x < this->center_->getStoneSize()/2.0) //!< If the stone touches the left edge of the level 115 valid.first =false;113 return false; 116 114 else if(position.x > (this->center_->getWidth()-0.5)*this->center_->getStoneSize()) //!< If the stone touches the right edge of the level 117 valid.first =false;115 return false; 118 116 119 117 for(std::vector<TetrisStone*>::const_iterator it = this->stones_.begin(); it != this->stones_.end(); ++it) … … 124 122 const Vector3& currentStonePosition = (*it)->getPosition(); //!< Saves the position of the currentStone 125 123 126 if((position.x == currentStonePosition.x) && (position.y == currentStonePosition.y)) 127 { 128 stone->setVelocity(Vector3::ZERO); 129 this->createStone(); 130 this->startStone(); 131 valid.first = false; 132 return valid; 133 }// This case applies if the stones overlap completely 134 } 135 136 return valid; 124 if((position.x == currentStonePosition.x) && abs(position.y-currentStonePosition.y) < this->center_->getStoneSize()) 125 return false; 126 } 127 128 return true; 137 129 } 138 130
Note: See TracChangeset
for help on using the changeset viewer.