- Timestamp:
- Apr 13, 2012, 5:44:29 PM (13 years ago)
- Location:
- code/branches/pCuts
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/pCuts/data/levels/tetris.oxw
r9084 r9085 47 47 <Template name=tetrisbrick> 48 48 <TetrisBrick camerapositiontemplate=tetrisbrickcameras> 49 <attached>50 <Model position="0,0,0" mesh="crate.mesh" scale=1 />51 </attached>52 49 </TetrisBrick> 53 50 </Template> -
code/branches/pCuts/src/modules/tetris/Tetris.cc
r9084 r9085 99 99 { 100 100 this->activeBrick_->setVelocity(Vector3::ZERO); 101 this->activeBrick_->releaseStones(this->center_); 102 //delete this->activeBrick_; //releasing the memory 101 103 this->createBrick(); 102 104 this->startBrick(); … … 120 122 121 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; 122 128 123 129 if((position.x == currentStonePosition.x) && abs(position.y-currentStonePosition.y) < this->center_->getStoneSize()) … … 145 151 stonePosition = rotateVector(stone->getPosition(), brick->getRotationCount()); 146 152 147 /*orxout()<< "stoneRelativePoistion: " << stonePosition << endl;148 orxout()<< "stoneTotalPoistion : " << position + stonePosition << endl;*/149 150 153 if(! this->isValidMove(stone, position + stonePosition )) // wrong position?? 151 154 { … … 168 171 if(this->activeBrick_->contains(*it)) 169 172 continue; 170 //TODO: is this rotation correct ?? 171 Vector3 currentStonePosition = rotateVector((*it)->getPosition(), this->activeBrick_->getRotationCount());173 //Vector3 currentStonePosition = rotateVector((*it)->getPosition(), this->activeBrick_->getRotationCount()); 174 const Vector3& currentStonePosition = (*it)->getPosition(); //!< Saves the position of the currentStone 172 175 //!< Saves the position of the currentStone 176 if(position.x == currentStonePosition.x) 177 { 178 orxout()<< "candidate found" << endl; 179 orxout()<< "position.y: "<< position.y << endl; 180 orxout()<< "urrentStonePosition.y: " << currentStonePosition.y << endl; 181 } 173 182 174 183 if((position.x == currentStonePosition.x) && (position.y < currentStonePosition.y + this->center_->getStoneSize())) 175 184 {//TODO: Why are such events not detected ?? 185 // Because currentStonePosition.x isn't calculated globally, but locally 176 186 orxout()<< "YEAY !!"<<endl; 177 187 this->activeBrick_->setPosition(Vector3(this->activeBrick_->getPosition().x, currentStonePosition.y+this->center_->getStoneSize(), this->activeBrick_->getPosition().z)); … … 207 217 /** 208 218 @brief 209 Nasty function that allocates memory!! it rolls a vector 90° * amount219 A Vector3 is rolled 90 * degrees * amount (anticlockwise rotation) 210 220 */ 211 221 Vector3 Tetris::rotateVector(Vector3 position, unsigned int amount) 212 222 { 213 214 223 int temp = 0; 215 224 for(unsigned int i = 0; i < amount; i++) … … 230 239 if (this->center_ != NULL) // There needs to be a TetrisCenterpoint, i.e. the area the game takes place. 231 240 { 232 // Create the first stone.241 // Create the first brick. 233 242 this->createBrick(); 234 243 } -
code/branches/pCuts/src/modules/tetris/TetrisBrick.cc
r9084 r9085 53 53 RegisterObject(TetrisBrick); 54 54 55 this->shapeIndex_ = 1; //<! TODO: random number between 0 and 755 this->shapeIndex_ = 4; //<! 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; … … 241 241 this->setVelocity(0.0f, 0.0f, 0.0f); 242 242 } 243 /** 244 @brief 245 Attaches stones to the Centerpoint. 246 */ 247 void TetrisBrick::releaseStones(TetrisCenterpoint* center) 248 { 249 for(unsigned int i = 0; i < brickStones_.size(); i++) 250 { 251 //this->brickStones_[i]->detachFromParent(); 252 253 //this->brickStones_[i]->detach(this); 254 //this->brickStones_[i]->attach(center); 255 } 256 257 } 243 258 244 259 } -
code/branches/pCuts/src/modules/tetris/TetrisBrick.h
r9084 r9085 72 72 { return this->rotationCount_;} 73 73 74 void releaseStones(TetrisCenterpoint* center); 75 74 76 protected: 75 77 void createBrick(void); //!< Create a cluster of TetrisStones -
code/branches/pCuts/src/modules/tetris/TetrisStone.cc
r9082 r9085 72 72 else if(!this->lockRotation_) //rotate when key up is pressed 73 73 { 74 orxout() << "The object should be rolled soon." << endl;75 74 this->lockRotation_ = true; // multiple calls of this function have to be filtered out. 76 75 this->rotationTimer_.setTimer(0.1f, false, createExecutor(createFunctor(&TetrisStone::unlockRotation, this)));
Note: See TracChangeset
for help on using the changeset viewer.