[Orxonox-commit 5136] r9801 - code/trunk/src/modules/tetris

jo at orxonox.net jo at orxonox.net
Thu Nov 21 21:26:33 CET 2013


Author: jo
Date: 2013-11-21 21:26:33 +0100 (Thu, 21 Nov 2013)
New Revision: 9801

Modified:
   code/trunk/src/modules/tetris/Tetris.cc
   code/trunk/src/modules/tetris/TetrisBrick.cc
   code/trunk/src/modules/tetris/TetrisScore.h
Log:
Eridicating a Tetris Bug, related to the positioning of a TetrisBrick in case of a brick-bottom-collision.

Modified: code/trunk/src/modules/tetris/Tetris.cc
===================================================================
--- code/trunk/src/modules/tetris/Tetris.cc	2013-11-21 17:59:04 UTC (rev 9800)
+++ code/trunk/src/modules/tetris/Tetris.cc	2013-11-21 20:26:33 UTC (rev 9801)
@@ -49,6 +49,7 @@
 #include "TetrisStone.h"
 #include "TetrisBrick.h"
 #include "infos/PlayerInfo.h"
+#include <cmath>
 
 namespace orxonox
 {
@@ -209,7 +210,10 @@
         // after we checked for collision with all stones, we also check for collision with the bottom
         if(position.y < this->center_->getStoneSize()/2.0f) //!< If the stone has reached the bottom of the level
         {
-            float yOffset = stone->getPosition().y + this->center_->getStoneSize()/2.0f;//calculate offset
+            float baseOffset = abs(stone->getPosition().y);
+            if (this->activeBrick_->getRotationCount() == 1 || this->activeBrick_->getRotationCount() == 3)
+                baseOffset = abs(stone->getPosition().x);
+            float yOffset = baseOffset + this->center_->getStoneSize()/2.0f;//calculate offset
             if(yOffset < 0) //catch brake-throughs
                 yOffset = 0;
             this->activeBrick_->setPosition(Vector3(this->activeBrick_->getPosition().x, yOffset, this->activeBrick_->getPosition().z));
@@ -387,6 +391,7 @@
         this->center_->attach(this->futureBrick_);
         float xPos = (this->center_->getWidth()*1.6f + ((this->center_->getWidth() % 2)*2-1)/2.0f)*this->center_->getStoneSize();
         float yPos = (this->center_->getHeight()-5.1f)*this->center_->getStoneSize();
+        
         this->futureBrick_->setPosition(xPos, yPos, 0.0f);
         this->futureBrick_->setGame(this);
     }

Modified: code/trunk/src/modules/tetris/TetrisBrick.cc
===================================================================
--- code/trunk/src/modules/tetris/TetrisBrick.cc	2013-11-21 17:59:04 UTC (rev 9800)
+++ code/trunk/src/modules/tetris/TetrisBrick.cc	2013-11-21 20:26:33 UTC (rev 9801)
@@ -106,24 +106,29 @@
         if(i == 0) //setting the first stone as
         {
             stone->setPosition(0.0f, 0.0f, 0.0f);
+            stone->setName("Base");
         }
         else if(i == 1)
         {
             stone->setPosition(0.0f, size_, 0.0f);
+            stone->setName("Y");
         }
         else if(i == 2)
         {
             if(this->shapeIndex_ == 1 || this->shapeIndex_ == 6 || this->shapeIndex_ == 7)
             {
             	stone->setPosition(0.0f, 2*size_, 0.0f);
+            	stone->setName("2Y");
             }
             else if(this->shapeIndex_ == 3 || this->shapeIndex_ == 4|| this->shapeIndex_ == 5)
             {
             	stone->setPosition(size_, 0, 0.0f);
+            	stone->setName("X");
             }
             else if(this->shapeIndex_ == 2)
             {
             	stone->setPosition(-size_, 0, 0.0f);
+            	stone->setName("-X");
             }
         }
         else if(i == 3)
@@ -131,22 +136,27 @@
             if(this->shapeIndex_ == 2 || this->shapeIndex_ == 5)
             {
             	stone->setPosition(size_, size_, 0.0f);
+            	stone->setName("XY");
             }
             else if(this->shapeIndex_ == 1)
             {
             	stone->setPosition(0, 3*size_, 0.0f);
+            	stone->setName("3Y");
             }
             else if(this->shapeIndex_ == 3 || this->shapeIndex_ == 7)
             {
             	stone->setPosition(-size_, 0, 0.0f);
+            	stone->setName("-X");
             }
             else if(this->shapeIndex_ == 4)
             {
             	stone->setPosition(-size_, size_, 0.0f);
+            	stone->setName("-XY");
             }
             else if(this->shapeIndex_ == 6)
             {
             	stone->setPosition(size_, 0, 0.0f);
+            	stone->setName("X");
             }
         }
     }

Modified: code/trunk/src/modules/tetris/TetrisScore.h
===================================================================
--- code/trunk/src/modules/tetris/TetrisScore.h	2013-11-21 17:59:04 UTC (rev 9800)
+++ code/trunk/src/modules/tetris/TetrisScore.h	2013-11-21 20:26:33 UTC (rev 9801)
@@ -20,7 +20,7 @@
  *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  *
  *   Author:
- *      Fabian 'x3n' Landau
+ *      Johannes Ritz
  *   Co-authors:
  *      ...
  *




More information about the Orxonox-commit mailing list