Changeset 8565
- Timestamp:
- May 24, 2011, 9:59:01 PM (14 years ago)
- Location:
- code/branches/presentation/src/modules/tetris
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation/src/modules/tetris/Tetris.cc
r8564 r8565 91 91 if(this->activeStone_ != NULL) 92 92 { 93 std::pair<bool, TetrisStone*> valid = this->isValid Move(this->activeStone_, this->activeStone_->getPosition());93 std::pair<bool, TetrisStone*> valid = this->isValidStonePosition(this->activeStone_, this->activeStone_->getPosition()); 94 94 if(!valid.first) 95 95 { … … 116 116 else if(position.x > (this->center_->getWidth()-0.5)*this->center_->getStoneSize()) //!< If the stone touches the right edge of the level 117 117 valid.first = false; 118 else if(position.y < this->center_->getStoneSize()/2.0) //!< If the stone has reached the bottom of the level119 {120 valid.first = false;121 stone->setPosition(Vector3(stone->getPosition().x, this->center_->getStoneSize()/2.0, stone->getPosition().z));122 }123 118 124 119 for(std::vector<TetrisStone*>::const_iterator it = this->stones_.begin(); it != this->stones_.end(); ++it) … … 137 132 return valid; 138 133 }// This case applies if the stones overlap completely 139 else if((position.x == currentStonePosition.x) && (position.y < currentStonePosition.y + this->center_->getStoneSize())) 134 } 135 136 return valid; 137 } 138 139 std::pair<bool, TetrisStone*> Tetris::isValidStonePosition(TetrisStone* stone, const Vector3& position) 140 { 141 assert(stone); 142 143 std::pair<bool, TetrisStone*> valid = std::pair<bool, TetrisStone*>(true, NULL); 144 145 if(position.y < this->center_->getStoneSize()/2.0) //!< If the stone has reached the bottom of the level 146 { 147 valid.first = false; 148 stone->setPosition(Vector3(stone->getPosition().x, this->center_->getStoneSize()/2.0, stone->getPosition().z)); 149 } 150 151 for(std::vector<TetrisStone*>::const_iterator it = this->stones_.begin(); it != this->stones_.end(); ++it) 152 { 153 if(stone == *it) 154 continue; 155 156 const Vector3& currentStonePosition = (*it)->getPosition(); //!< Saves the position of the currentStone 157 158 if((position.x == currentStonePosition.x) && (position.y < currentStonePosition.y + this->center_->getStoneSize())) 140 159 { 141 160 valid.first = false; -
code/branches/presentation/src/modules/tetris/Tetris.h
r8564 r8565 78 78 void createStone(void); 79 79 void cleanup(void); //!< Cleans up the Gametype by destroying the ball and the bats. 80 std::pair<bool, TetrisStone*> isValidStonePosition(TetrisStone* stone, const Vector3& position); 80 81 81 82 PlayerInfo* player_;
Note: See TracChangeset
for help on using the changeset viewer.