Changeset 8567 for code/branches/presentation/src/modules/tetris
- Timestamp:
- May 24, 2011, 10:17:10 PM (13 years ago)
- Location:
- code/branches/presentation/src/modules/tetris
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation/src/modules/tetris/Tetris.cc
r8566 r8567 91 91 if(this->activeStone_ != NULL) 92 92 { 93 std::pair<bool, TetrisStone*> valid = this->isValidStonePosition(this->activeStone_, this->activeStone_->getPosition()); 94 if(!valid.first) 93 if(!this->isValidStonePosition(this->activeStone_, this->activeStone_->getPosition())) 95 94 { 96 95 this->activeStone_->setVelocity(Vector3::ZERO); 97 if(valid.second != NULL)98 {99 Vector3 position = Vector3(this->activeStone_->getPosition().x, valid.second->getPosition().y+this->center_->getStoneSize(), this->activeStone_->getPosition().z);100 this->activeStone_->setPosition(position);101 }102 96 this->createStone(); 103 97 this->startStone(); … … 129 123 } 130 124 131 std::pair<bool, TetrisStone*>Tetris::isValidStonePosition(TetrisStone* stone, const Vector3& position)125 bool Tetris::isValidStonePosition(TetrisStone* stone, const Vector3& position) 132 126 { 133 127 assert(stone); 134 128 135 std::pair<bool, TetrisStone*> valid = std::pair<bool, TetrisStone*>(true, NULL);136 137 129 if(position.y < this->center_->getStoneSize()/2.0) //!< If the stone has reached the bottom of the level 138 130 { 139 valid.first = false;140 131 stone->setPosition(Vector3(stone->getPosition().x, this->center_->getStoneSize()/2.0, stone->getPosition().z)); 132 return false; 141 133 } 142 134 … … 150 142 if((position.x == currentStonePosition.x) && (position.y < currentStonePosition.y + this->center_->getStoneSize())) 151 143 { 152 valid.first = false; 153 valid.second = *it; 154 return valid; 144 this->activeStone_->setPosition(Vector3(this->activeStone_->getPosition().x, currentStonePosition.y+this->center_->getStoneSize(), this->activeStone_->getPosition().z)); 145 return false; 155 146 }// This case applies if the stones overlap partially vertically 156 147 } 157 148 158 return valid;149 return true; 159 150 } 160 151 -
code/branches/presentation/src/modules/tetris/Tetris.h
r8566 r8567 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 bool isValidStonePosition(TetrisStone* stone, const Vector3& position); 81 81 82 82 PlayerInfo* player_;
Note: See TracChangeset
for help on using the changeset viewer.