[Orxonox-commit 4659] r9330 - code/branches/presentation2012merge/src/modules/tetris

landauf at orxonox.net landauf at orxonox.net
Sun Jul 22 19:23:51 CEST 2012


Author: landauf
Date: 2012-07-22 19:23:51 +0200 (Sun, 22 Jul 2012)
New Revision: 9330

Modified:
   code/branches/presentation2012merge/src/modules/tetris/Tetris.cc
   code/branches/presentation2012merge/src/modules/tetris/Tetris.h
Log:
added deterministic stop criterion to end tetris match (independent of time)

Modified: code/branches/presentation2012merge/src/modules/tetris/Tetris.cc
===================================================================
--- code/branches/presentation2012merge/src/modules/tetris/Tetris.cc	2012-07-22 16:46:05 UTC (rev 9329)
+++ code/branches/presentation2012merge/src/modules/tetris/Tetris.cc	2012-07-22 17:23:51 UTC (rev 9330)
@@ -73,7 +73,6 @@
         this->starttimer_.stopTimer();
 
         this->player_ = NULL;
-        this->endGameCriteria_ = 0.0f;
         this->setHUDTemplate("TetrisHUD");
         this->futureBrick_ = 0;
     }
@@ -116,7 +115,6 @@
 
         if((this->activeBrick_ != NULL)&&(!this->hasEnded()))
         {
-            this->endGameCriteria_ += dt;
             if(!this->isValidBrickPosition(this->activeBrick_))
             {
                 for (unsigned int i = 0; i < this->activeBrick_->getNumberOfStones(); i++)
@@ -124,11 +122,7 @@
                 this->activeBrick_->setVelocity(Vector3::ZERO);
                 this->activeBrick_->releaseStones(this->center_);
                 this->findFullRows();
-                if(this->endGameCriteria_ < 0.1f) //end game if two bricks are created within a 0.1s interval.
-                    this->end();
-                else
-                    this->startBrick();
-                this->endGameCriteria_ = 0.0f;
+                this->startBrick();
             }
         }
     }
@@ -377,6 +371,10 @@
 
         // create a new future brick
         this->createBrick();
+
+        // check if the new brick is in a valid position, otherwise end the game
+        if (!this->isValidBrickPosition(this->activeBrick_))
+            this->end();
     }
 
     void Tetris::createBrick(void)             //TODO: random rotation offset between 0 and 3 (times 90°)

Modified: code/branches/presentation2012merge/src/modules/tetris/Tetris.h
===================================================================
--- code/branches/presentation2012merge/src/modules/tetris/Tetris.h	2012-07-22 16:46:05 UTC (rev 9329)
+++ code/branches/presentation2012merge/src/modules/tetris/Tetris.h	2012-07-22 17:23:51 UTC (rev 9330)
@@ -96,7 +96,6 @@
             WeakPtr<TetrisBrick> futureBrick_;
 
             Timer starttimer_; //!< A timer to delay the start of the game.
-            float endGameCriteria_; //<! Works as a timer which is resetted, whenever a brick is created.
     };
 }
 




More information about the Orxonox-commit mailing list