Changeset 9323 for code/branches/presentation2012merge
- Timestamp:
- Jul 21, 2012, 6:32:02 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation2012merge/src/modules/tetris/Tetris.cc
r9322 r9323 108 108 if((this->activeBrick_ != NULL)&&(!this->hasEnded())) 109 109 { 110 110 this->endGameCriteria_ += dt; 111 111 if(!this->isValidBrickPosition(this->activeBrick_, this->activeBrick_->getPosition())) 112 112 { … … 160 160 Vector3 stonePosition; //the current stone's offset to position 161 161 if(isRotation) 162 162 stonePosition = rotateVector(stone->getPosition(), brick->getRotationCount()+1); 163 163 else 164 164 stonePosition = rotateVector(stone->getPosition(), brick->getRotationCount()); … … 204 204 float y_offset = static_cast<int>((this->activeBrick_->getPosition().y-currentStonePosition.y+10)/10)*10 + currentStonePosition.y; 205 205 if(y_offset < 0) //filter out extreme cases (very rare bug) 206 206 y_offset = 0; 207 207 this->activeBrick_->setPosition(Vector3(this->activeBrick_->getPosition().x, y_offset, this->activeBrick_->getPosition().z)); 208 208 return false; … … 213 213 if(position.y < this->center_->getStoneSize()/2.0f) //!< If the stone has reached the bottom of the level 214 214 { 215 216 217 218 215 float yOffset = stone->getPosition().y + this->center_->getStoneSize()/2.0f;//calculate offset 216 if(yOffset < 0) //catch brake-throughs 217 yOffset = 0; 218 this->activeBrick_->setPosition(Vector3(this->activeBrick_->getPosition().x, yOffset, this->activeBrick_->getPosition().z)); 219 219 return false; 220 220 } … … 246 246 Vector3 Tetris::rotateVector(Vector3 position, unsigned int amount) 247 247 { 248 248 float temp = 0; 249 249 for(unsigned int i = 0; i < amount; i++) 250 250 { … … 421 421 void Tetris::findFullRows() 422 422 { 423 424 425 426 427 423 unsigned int correctPosition = 0; 424 unsigned int stonesPerRow = 0; 425 for (unsigned int row = 0; row < this->center_->getHeight(); row++) 426 { 427 stonesPerRow = 0; 428 428 for(std::vector<TetrisStone*>::iterator it = this->stones_.begin(); it != this->stones_.end(); ++it) 429 429 { 430 430 correctPosition = static_cast<unsigned int>(((*it)->getPosition().y - 5)/this->center_->getStoneSize()); 431 431 if(correctPosition == row) 432 432 { … … 450 450 { 451 451 if(static_cast<unsigned int>(((*it)->getPosition().y - 5)/this->center_->getStoneSize()) == row) 452 453 452 (*it)->setPosition(Vector3(-50,-50,100)); 453 //{(*it)->destroy(); this->stones_.erase(it); orxout()<< "destroy row "<<endl;}//experimental 454 454 } 455 455 // adjust height of stones above the deleted row //TODO: check if this could be a source of a bug.
Note: See TracChangeset
for help on using the changeset viewer.