Changeset 9086
- Timestamp:
- Apr 14, 2012, 3:32:56 PM (13 years ago)
- Location:
- code/branches/pCuts/src/modules/tetris
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/pCuts/src/modules/tetris/Tetris.cc
r9085 r9086 122 122 123 123 const Vector3& currentStonePosition = (*it)->getPosition(); //!< Saves the position of the currentStone 124 orxout()<< "position.x: " << position.x << endl;125 orxout()<< "currentStonePosition.x: " << currentStonePosition.x << endl;126 if(position.x == currentStonePosition.x)127 orxout()<< "NON Valid Move Candidate" <<endl;128 124 129 125 if((position.x == currentStonePosition.x) && abs(position.y-currentStonePosition.y) < this->center_->getStoneSize()) … … 174 170 const Vector3& currentStonePosition = (*it)->getPosition(); //!< Saves the position of the currentStone 175 171 //!< Saves the position of the currentStone 176 if(position.x == currentStonePosition.x) 172 173 if((position.x == currentStonePosition.x) && (position.y < currentStonePosition.y + this->center_->getStoneSize())) 177 174 { 178 orxout()<< "candidate found" << endl;179 orxout()<< "position.y: "<< position.y << endl;180 orxout()<< "urrentStonePosition.y: " << currentStonePosition.y << endl;181 }182 183 if((position.x == currentStonePosition.x) && (position.y < currentStonePosition.y + this->center_->getStoneSize()))184 {//TODO: Why are such events not detected ??185 // Because currentStonePosition.x isn't calculated globally, but locally186 orxout()<< "YEAY !!"<<endl;187 175 this->activeBrick_->setPosition(Vector3(this->activeBrick_->getPosition().x, currentStonePosition.y+this->center_->getStoneSize(), this->activeBrick_->getPosition().z)); 188 176 return false; … … 316 304 // Get camera settings 317 305 cameraIndex = this->activeBrick_->getCurrentCameraIndex(); 318 orxout() << "cameraIndex: " << this->activeBrick_->getCurrentCameraIndex() << endl;319 306 this->player_->stopControl(); 320 307 } … … 325 312 this->player_->startControl(this->activeBrick_); 326 313 this->activeBrick_->setVelocity(0.0f, -this->center_->getStoneSpeed(), 0.0f); 327 orxout() << "velocity: " << this->center_->getStoneSpeed() << endl;328 314 this->activeBrick_->setCameraPosition(cameraIndex); 329 315 } … … 376 362 } 377 363 364 /** 365 @brief Check each row if it is full. Remove all full rows. Let all stones above the deleted row sink down. 366 @brief Manage score. 367 */ 368 void Tetris::clearFullRow() 369 { 370 unsigned int stonesPerRow = 0; 371 for (unsigned int row = 0; row < this->center_->getHeight()/this->center_->getStoneSize(); row++) 372 { 373 stonesPerRow = 0; 374 for(std::vector<TetrisStone*>::const_reverse_iterator it = this->stones_.rbegin(); it != this->stones_.rend(); ++it) 375 { 376 if((*it)->getPosition().y == row) 377 stonesPerRow++; 378 if(stonesPerRow == this->center_->getWidth()/this->center_->getStoneSize()) 379 orxout()<< "CANDIDATE FOUND in row " << row <<endl; 380 } 381 382 } 383 } 384 378 385 } -
code/branches/pCuts/src/modules/tetris/Tetris.h
r9084 r9086 73 73 bool isValidMove(TetrisStone* stone, const Vector3& position); 74 74 bool isValidMove(TetrisBrick* brick, const Vector3& position, bool isRotation); 75 Vector3 rotateVector(Vector3 position, unsigned int amount); 75 76 76 77 protected: … … 84 85 bool isValidStonePosition(TetrisStone* stone, const Vector3& position); 85 86 bool isValidBrickPosition(TetrisBrick* brick, const Vector3& position); 86 Vector3 rotateVector(Vector3 position, unsigned int amount); 87 void clearFullRow(void); 88 87 89 88 90 PlayerInfo* player_; -
code/branches/pCuts/src/modules/tetris/TetrisBrick.cc
r9085 r9086 177 177 return NULL; 178 178 } 179 179 //TODO: refactor this function; is not needed if brickstones are added to Tetris::stones_ after collision. 180 180 bool TetrisBrick::contains(TetrisStone* stone) 181 181 { … … 241 241 this->setVelocity(0.0f, 0.0f, 0.0f); 242 242 } 243 243 244 /** 244 245 @brief … … 247 248 void TetrisBrick::releaseStones(TetrisCenterpoint* center) 248 249 { 250 assert(this->tetris_); 249 251 for(unsigned int i = 0; i < brickStones_.size(); i++) 250 252 { 251 //this->brickStones_[i]->detachFromParent(); 252 253 //this->brickStones_[i]->detach(this); 254 //this->brickStones_[i]->attach(center); 253 this->brickStones_[i]->detachFromParent(); 254 this->brickStones_[i]->attachToParent(center); 255 this->brickStones_[i]->setPosition(this->getPosition()+this->tetris_->rotateVector(this->brickStones_[i]->getPosition(),this->rotationCount_ )); 255 256 } 256 257
Note: See TracChangeset
for help on using the changeset viewer.