- Timestamp:
- Jul 22, 2012, 5:57:54 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation2012merge/src/modules/tetris/Tetris.cc
r9326 r9328 67 67 RegisterObject(Tetris); 68 68 69 this->activeBrick_ = NULL;69 this->activeBrick_ = 0; 70 70 71 71 // Pre-set the timer, but don't start it yet. … … 76 76 this->endGameCriteria_ = 0.0f; 77 77 this->setHUDTemplate("TetrisHUD"); 78 this->futureBrick_ = NULL;78 this->futureBrick_ = 0; 79 79 } 80 80 … … 95 95 void Tetris::cleanup() 96 96 { 97 if (this->isInitialized()) 98 { 99 if (this->activeBrick_) 100 { 101 this->activeBrick_->destroy(); 102 this->activeBrick_ = NULL; 103 } 104 if (this->futureBrick_) 105 { 106 this->futureBrick_->destroy(); 107 this->futureBrick_ = NULL; 108 } 109 110 for (std::list<TetrisStone*>::iterator it = this->stones_.begin(); it != this->stones_.end(); ++it) 111 (*it)->destroy(); 112 this->stones_.clear(); 113 } 97 if (this->activeBrick_) 98 { 99 this->activeBrick_->destroy(); 100 this->activeBrick_ = 0; 101 } 102 if (this->futureBrick_) 103 { 104 this->futureBrick_->destroy(); 105 this->futureBrick_ = 0; 106 } 107 108 for (std::list<SmartPtr<TetrisStone> >::iterator it = this->stones_.begin(); it != this->stones_.end(); ++it) 109 (*it)->destroy(); 110 this->stones_.clear(); 114 111 } 115 112 … … 129 126 this->findFullRows(); 130 127 if(this->endGameCriteria_ < 0.1f) //end game if two bricks are created within a 0.1s interval. 131 {132 128 this->end(); 133 return; 134 } 135 this->startBrick(); 129 else 130 this->startBrick(); 136 131 this->endGameCriteria_ = 0.0f; 137 132 } … … 148 143 return false; 149 144 150 for(std::list< TetrisStone*>::const_iterator it = this->stones_.begin(); it != this->stones_.end(); ++it)145 for(std::list<SmartPtr<TetrisStone> >::const_iterator it = this->stones_.begin(); it != this->stones_.end(); ++it) 151 146 { 152 147 const Vector3& currentStonePosition = (*it)->getPosition(); //!< Saves the position of the currentStone … … 201 196 202 197 // we use a reverse iterator because we have to check for collisions with the topmost stones first 203 for(std::list< TetrisStone*>::const_reverse_iterator it = this->stones_.rbegin(); it != this->stones_.rend(); ++it)198 for(std::list<SmartPtr<TetrisStone> >::const_reverse_iterator it = this->stones_.rbegin(); it != this->stones_.rend(); ++it) 204 199 { 205 200 //Vector3 currentStonePosition = rotateVector((*it)->getPosition(), this->activeBrick_->getRotationCount()); … … 364 359 // Make the last brick to be created the active brick. 365 360 this->activeBrick_ = this->futureBrick_; 366 this->futureBrick_ = NULL;361 this->futureBrick_ = 0; 367 362 368 363 // set its position … … 432 427 { 433 428 stonesPerRow = 0; 434 for(std::list< TetrisStone*>::iterator it = this->stones_.begin(); it != this->stones_.end(); )435 { 436 std::list< TetrisStone*>::iterator it_temp = it++;429 for(std::list<SmartPtr<TetrisStone> >::iterator it = this->stones_.begin(); it != this->stones_.end(); ) 430 { 431 std::list<SmartPtr<TetrisStone> >::iterator it_temp = it++; 437 432 correctPosition = static_cast<unsigned int>(((*it_temp)->getPosition().y - 5)/this->center_->getStoneSize()); 438 433 if(correctPosition == row) … … 454 449 void Tetris::clearRow(unsigned int row) 455 450 {// clear the full row 456 for(std::list< TetrisStone*>::iterator it = this->stones_.begin(); it != this->stones_.end(); )451 for(std::list<SmartPtr<TetrisStone> >::iterator it = this->stones_.begin(); it != this->stones_.end(); ) 457 452 { 458 453 if(static_cast<unsigned int>(((*it)->getPosition().y - 5)/this->center_->getStoneSize()) == row) … … 465 460 } 466 461 // adjust height of stones above the deleted row //TODO: check if this could be a source of a bug. 467 for(std::list< TetrisStone*>::iterator it = this->stones_.begin(); it != this->stones_.end(); ++it)462 for(std::list<SmartPtr<TetrisStone> >::iterator it = this->stones_.begin(); it != this->stones_.end(); ++it) 468 463 { 469 464 if(static_cast<unsigned int>(((*it)->getPosition().y - 5)/this->center_->getStoneSize()) > row)
Note: See TracChangeset
for help on using the changeset viewer.