Changeset 9084 for code/branches/pCuts/src/modules/tetris/TetrisBrick.cc
- Timestamp:
- Apr 12, 2012, 7:05:57 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/pCuts/src/modules/tetris/TetrisBrick.cc
r9083 r9084 53 53 RegisterObject(TetrisBrick); 54 54 55 this->shapeIndex_ = 3; //<! TODO: random number between 0 and 755 this->shapeIndex_ = 1; //<! TODO: random number between 0 and 7 56 56 this->stonesPerBrick_ = 4; //<! most tetris bricks is formed by 4 stones 57 57 this->delay_ = false; … … 60 60 this->tetris_ = this->getTetris(); 61 61 this->size_ = 10.0f; //TODO: fix this via this->tetris_->center_->getStoneSize(); 62 63 62 this->rotationCount_ = 0; 64 63 this->createBrick(); //<! create a whole new Brick; 65 64 } … … 79 78 // Create a new stone and add it to the brick. 80 79 TetrisStone* stone = new TetrisStone(this); 81 stone->setHealth(1.0f); //TODO: is this value low enough ?80 stone->setHealth(1.0f); 82 81 this->brickStones_.push_back(stone); 83 82 this->attach(stone); … … 156 155 } 157 156 158 bool TetrisBrick::isValidMove(Vector3& position) 159 { 160 161 for(unsigned int i = 0; i < this->stonesPerBrick_ ; i++) 162 {//TODO: check if isValidMove works with this function, 163 if(this->tetris_->isValidMove(this->brickStones_[i], position)) 164 continue; 165 else 166 return false; 167 } 168 return true; 157 bool TetrisBrick::isValidMove(const Vector3& position, bool isRotation = false) 158 { 159 return this->tetris_->isValidMove(this,position, isRotation); 169 160 } 170 161 … … 211 202 else if(!this->lockRotation_) //rotate when key up is pressed 212 203 { 213 orxout() << "The object should be rolled soon." << endl; 204 if(!isValidMove(this->getPosition(), true)) //catch illegal rotations 205 return; 214 206 this->lockRotation_ = true; // multiple calls of this function have to be filtered out. 215 207 this->rotationTimer_.setTimer(0.1f, false, createExecutor(createFunctor(&TetrisBrick::unlockRotation, this))); 216 208 Quaternion q(Degree(90), Vector3::UNIT_Z); 217 209 this->setOrientation(this->getOrientation()*q); //rotation: roll 90° 218 210 this->rotationCount_ = (this->rotationCount_ + 1) % 4; 219 211 } 220 212 }
Note: See TracChangeset
for help on using the changeset viewer.