[Orxonox-commit 4414] r9085 - in code/branches/pCuts: data/levels src/modules/tetris

jo at orxonox.net jo at orxonox.net
Fri Apr 13 17:44:29 CEST 2012


Author: jo
Date: 2012-04-13 17:44:29 +0200 (Fri, 13 Apr 2012)
New Revision: 9085

Modified:
   code/branches/pCuts/data/levels/tetris.oxw
   code/branches/pCuts/src/modules/tetris/Tetris.cc
   code/branches/pCuts/src/modules/tetris/TetrisBrick.cc
   code/branches/pCuts/src/modules/tetris/TetrisBrick.h
   code/branches/pCuts/src/modules/tetris/TetrisStone.cc
Log:
backup checkin - still the same bugs experiencable

Modified: code/branches/pCuts/data/levels/tetris.oxw
===================================================================
--- code/branches/pCuts/data/levels/tetris.oxw	2012-04-12 17:05:57 UTC (rev 9084)
+++ code/branches/pCuts/data/levels/tetris.oxw	2012-04-13 15:44:29 UTC (rev 9085)
@@ -46,9 +46,6 @@
 
 <Template name=tetrisbrick>
   <TetrisBrick camerapositiontemplate=tetrisbrickcameras>
-    <attached>
-      <Model position="0,0,0" mesh="crate.mesh" scale=1 />
-    </attached>
   </TetrisBrick>
 </Template>
 

Modified: code/branches/pCuts/src/modules/tetris/Tetris.cc
===================================================================
--- code/branches/pCuts/src/modules/tetris/Tetris.cc	2012-04-12 17:05:57 UTC (rev 9084)
+++ code/branches/pCuts/src/modules/tetris/Tetris.cc	2012-04-13 15:44:29 UTC (rev 9085)
@@ -98,6 +98,8 @@
             if(!this->isValidBrickPosition(this->activeBrick_, this->activeBrick_->getPosition()))
             {
                 this->activeBrick_->setVelocity(Vector3::ZERO);
+                this->activeBrick_->releaseStones(this->center_);
+                //delete this->activeBrick_; //releasing the memory
                 this->createBrick();
                 this->startBrick();
             }
@@ -119,6 +121,10 @@
                 continue;
 
             const Vector3& currentStonePosition = (*it)->getPosition(); //!< Saves the position of the currentStone
+            orxout()<< "position.x: " << position.x << endl;
+            orxout()<< "currentStonePosition.x: " << currentStonePosition.x << endl;
+            if(position.x == currentStonePosition.x)
+            	orxout()<< "NON Valid Move Candidate" <<endl;
 
             if((position.x == currentStonePosition.x) && abs(position.y-currentStonePosition.y) < this->center_->getStoneSize())
                 return false;
@@ -144,9 +150,6 @@
             else
                 stonePosition = rotateVector(stone->getPosition(), brick->getRotationCount());
 
-            /*orxout()<< "stoneRelativePoistion: " << stonePosition << endl;
-            orxout()<< "stoneTotalPoistion   : " << position + stonePosition << endl;*/
-
             if(! this->isValidMove(stone, position + stonePosition )) // wrong position??
             {
                 return false;
@@ -167,12 +170,19 @@
         {
             if(this->activeBrick_->contains(*it))
                 continue;
-//TODO: is this rotation correct ??
-            Vector3 currentStonePosition = rotateVector((*it)->getPosition(), this->activeBrick_->getRotationCount());
+            //Vector3 currentStonePosition = rotateVector((*it)->getPosition(), this->activeBrick_->getRotationCount());
+            const Vector3& currentStonePosition = (*it)->getPosition(); //!< Saves the position of the currentStone
             //!< Saves the position of the currentStone
+            if(position.x == currentStonePosition.x)
+            {
+                orxout()<< "candidate found" << endl;
+                orxout()<< "position.y: "<< position.y << endl;
+                orxout()<< "urrentStonePosition.y: " << currentStonePosition.y << endl;
+            }
 
             if((position.x == currentStonePosition.x) && (position.y < currentStonePosition.y + this->center_->getStoneSize()))
             {//TODO: Why are such events not detected ??
+             // Because currentStonePosition.x isn't calculated globally, but locally
                 orxout()<< "YEAY !!"<<endl;
                 this->activeBrick_->setPosition(Vector3(this->activeBrick_->getPosition().x, currentStonePosition.y+this->center_->getStoneSize(), this->activeBrick_->getPosition().z));
                 return false;
@@ -206,11 +216,10 @@
 
     /**
     @brief
-        Nasty function that allocates memory!! it rolls a vector 90° * amount
+        A Vector3 is rolled 90 * degrees * amount (anticlockwise rotation)
     */
     Vector3 Tetris::rotateVector(Vector3 position, unsigned int amount)
     {
-
     	int temp = 0;
         for(unsigned int i = 0; i < amount; i++)
         {
@@ -229,7 +238,7 @@
     {
         if (this->center_ != NULL) // There needs to be a TetrisCenterpoint, i.e. the area the game takes place.
         {
-            // Create the first stone.
+            // Create the first brick.
             this->createBrick();
         }
         else // If no centerpoint was specified, an error is thrown and the level is exited.

Modified: code/branches/pCuts/src/modules/tetris/TetrisBrick.cc
===================================================================
--- code/branches/pCuts/src/modules/tetris/TetrisBrick.cc	2012-04-12 17:05:57 UTC (rev 9084)
+++ code/branches/pCuts/src/modules/tetris/TetrisBrick.cc	2012-04-13 15:44:29 UTC (rev 9085)
@@ -52,7 +52,7 @@
     {
         RegisterObject(TetrisBrick);
 
-        this->shapeIndex_ = 1; //<! TODO: random number between 0 and 7
+        this->shapeIndex_ = 4; //<! TODO: random number between 0 and 7
         this->stonesPerBrick_ = 4; //<! most tetris bricks is formed by 4 stones
         this->delay_ = false;
         this->delayTimer_.setTimer(0.2f, false, createExecutor(createFunctor(&TetrisBrick::enableMovement, this)));
@@ -240,5 +240,20 @@
     {
         this->setVelocity(0.0f, 0.0f, 0.0f);
     }
+    /**
+    @brief
+        Attaches stones to the Centerpoint.
+    */
+    void TetrisBrick::releaseStones(TetrisCenterpoint* center)
+    {
+        for(unsigned int i = 0; i < brickStones_.size(); i++)
+        {
+            //this->brickStones_[i]->detachFromParent();
 
+            //this->brickStones_[i]->detach(this);
+            //this->brickStones_[i]->attach(center);
+        }
+
+    }
+
 }

Modified: code/branches/pCuts/src/modules/tetris/TetrisBrick.h
===================================================================
--- code/branches/pCuts/src/modules/tetris/TetrisBrick.h	2012-04-12 17:05:57 UTC (rev 9084)
+++ code/branches/pCuts/src/modules/tetris/TetrisBrick.h	2012-04-13 15:44:29 UTC (rev 9085)
@@ -71,6 +71,8 @@
             unsigned int getRotationCount(void)
                 { return this->rotationCount_;}
 
+            void releaseStones(TetrisCenterpoint* center);
+
         protected:
             void createBrick(void); //!< Create a cluster of TetrisStones
             void formBrick(TetrisStone* stone, unsigned int i);

Modified: code/branches/pCuts/src/modules/tetris/TetrisStone.cc
===================================================================
--- code/branches/pCuts/src/modules/tetris/TetrisStone.cc	2012-04-12 17:05:57 UTC (rev 9084)
+++ code/branches/pCuts/src/modules/tetris/TetrisStone.cc	2012-04-13 15:44:29 UTC (rev 9085)
@@ -71,7 +71,6 @@
         }
         else if(!this->lockRotation_) //rotate when key up is pressed
         {
-            orxout() << "The object should be rolled soon." << endl;
             this->lockRotation_ = true; // multiple calls of this function have to be filtered out.
             this->rotationTimer_.setTimer(0.1f, false, createExecutor(createFunctor(&TetrisStone::unlockRotation, this)));
             Quaternion q(Degree(90), Vector3::UNIT_Z);




More information about the Orxonox-commit mailing list