Index: /code/branches/tetris/data/levels/tetris.oxw
===================================================================
--- /code/branches/tetris/data/levels/tetris.oxw	(revision 8536)
+++ /code/branches/tetris/data/levels/tetris.oxw	(revision 8537)
@@ -50,5 +50,5 @@
     <?lua end ?>
 
-    <TetrisCenterpoint name=tetriscenter width=11 height=15 stoneSize=10 stoneTemplate=tetrisstone stoneSpeed=5 position="-55,-75,0">
+    <TetrisCenterpoint name=tetriscenter width=11 height=15 stoneSize=10 stoneTemplate=tetrisstone stoneSpeed=10 position="-55,-75,0">
         <attached>
             <Model position="55,-1,0" mesh="cube.mesh" scale3D="57,1,11" />
Index: /code/branches/tetris/src/modules/tetris/Tetris.cc
===================================================================
--- /code/branches/tetris/src/modules/tetris/Tetris.cc	(revision 8536)
+++ /code/branches/tetris/src/modules/tetris/Tetris.cc	(revision 8537)
@@ -82,37 +82,37 @@
         
     }
-    
+
     void Tetris::tick(float dt)
     {
         SUPER(Tetris, tick, dt);
-        
-        TetrisStone* stone = this->activeStone_;
-        if(stone != NULL)
-        {
-            // Get the current position of the active stone
-            Vector3 position = stone->getPosition();
-            
-            if(position.x < this->center_->getStoneSize()/2.0)  //!< If the stone touches the left edge of the level
-                position.x = this->center_->getStoneSize()/2.0;
-            else if(position.x > (this->center_->getWidth()-0.5)*this->center_->getStoneSize()) //!< If the stone touches the right edge of the level
-                position.x = (this->center_->getWidth()-0.5)*this->center_->getStoneSize();
-
-            if(!this->correctStonePos(stone)) //!< If the stone touches another stone
-            {
-                stone->setVelocity(Vector3::ZERO);
-                this->createStone();
-                this->startStone();
-            }
-
-            if(position.y < this->center_->getStoneSize()/2.0) //!< If the stone has reached the bottom of the level
-            {
-                position.y = this->center_->getStoneSize()/2.0;
-                stone->setVelocity(Vector3::ZERO);
-                this->createStone();
-                this->startStone();
-            }
-            
-            stone->setPosition(position);
-        }
+
+        if(this->activeStone_ != NULL && !this->isValidMove(this->activeStone_, this->activeStone_->getPosition()))
+        {
+            this->activeStone_->setVelocity(Vector3::ZERO);
+            //this->grid_[(int)(position.x/this->center_->getStoneSize())][(int)(position.y/this->center_->getStoneSize())] = true;
+            this->createStone();
+            this->startStone();
+        }
+    }
+
+    bool Tetris::isValidMove(TetrisStone* stone, const Vector3& position)
+    {
+        assert(stone);
+        
+        if(position.x < this->center_->getStoneSize()/2.0)  //!< If the stone touches the left edge of the level
+            return false;
+        else if(position.x > (this->center_->getWidth()-0.5)*this->center_->getStoneSize()) //!< If the stone touches the right edge of the level
+            return false;
+        
+        if(position.y < this->center_->getStoneSize()/2.0) //!< If the stone has reached the bottom of the level
+        {
+            stone->setVelocity(Vector3::ZERO);
+            //this->grid_[(int)(position.x/this->center_->getStoneSize())][(int)(position.y/this->center_->getStoneSize())] = true;
+            this->createStone();
+            this->startStone();
+            return false;
+        }
+
+        return this->correctStonePos(stone, position);
     }
 
@@ -135,5 +135,5 @@
         }
 
-        // Start the timer. After it has expired the ball is started.
+        // Start the timer. After it has expired the stone is started.
         this->starttimer_.startTimer();
 
@@ -227,4 +227,5 @@
         float yPos = (this->center_->getHeight()-0.5)*this->center_->getStoneSize();
         stone->setPosition(xPos, yPos, 0.0f);
+        stone->setGame(this);
     }
 
@@ -235,22 +236,29 @@
         Returns whether the supplied stone is in the correct position.
     */
-    bool Tetris::correctStonePos(TetrisStone* stone)
-    {
+    bool Tetris::correctStonePos(TetrisStone* stone, const Vector3& position)
+    {
+        assert(stone);
+
         for(std::vector<TetrisStone*>::const_iterator it = this->stones_.begin(); it != this->stones_.end(); ++it)
         {
-            TetrisStone* currentStone = it->_Ptr(); //!< Gives access to the current stone in the list
-            Vector3 currentStonePosition = it->_Ptr()->getPosition(); //!< Saves the position of the currentStone
-            Vector3 stonePosition = stone->getPosition(); //!< Saves the position of the supplied stone
+            if(stone == *it)
+                continue;
+
+            Vector3 currentStonePosition = (*it)->getPosition(); //!< Saves the position of the currentStone
             
-            // @TODO:   Use the TetrisStone member functions to check both stones for an overlap.
-            //          Also make sure to correct the stone position accordingly.
-            //
-            // This case applies if the stones overlap completely
-            //if((stonePosition.x == currentStonePosition.x) && (stonePosition.y == currentStonePosition.y))
-            // This case applies if the stones overlap partially vertically
-            //if(stonePosition.y - stone->getHeight()/2 < currentStonePosition.y + currentStone->getHeight()/2)
-
-            
-        }
+            if((position.x == currentStonePosition.x) && (position.y == currentStonePosition.y))
+            {
+                stone->setVelocity(Vector3::ZERO);
+                this->createStone();
+                this->startStone();
+                return false;
+            }// This case applies if the stones overlap completely
+            if((position.x == currentStonePosition.x) && (position.y < currentStonePosition.y + this->center_->getStoneSize()))
+            {
+                return false;
+            }// This case applies if the stones overlap partially vertically
+        }
+
+        return true;
     }
 
@@ -266,3 +274,20 @@
     }
 
+    /**
+    @brief Set the TetrisCenterpoint (the playing field).
+    @param center A pointer to the TetrisCenterpoint to be set.
+    */
+    void Tetris::setCenterpoint(TetrisCenterpoint* center)
+    {
+        this->center_ = center;
+
+        /*this->grid_.resize(this->center_->getWidth());
+        for(std::vector< std::vector<bool> >::iterator it = this->grid_.begin(); it != this->grid_.end(); it++)
+        {
+            (*it).resize(this->center_->getHeight());
+            for(std::vector<bool>::iterator it2 = (*it).begin(); it2 != (*it).end(); it2++)
+                (*it).insert(it2, false);
+        }*/
+    }
+
 }
Index: /code/branches/tetris/src/modules/tetris/Tetris.h
===================================================================
--- /code/branches/tetris/src/modules/tetris/Tetris.h	(revision 8536)
+++ /code/branches/tetris/src/modules/tetris/Tetris.h	(revision 8537)
@@ -56,29 +56,27 @@
         public:
             Tetris(BaseObject* creator); //!< Constructor. Registers and initializes the object.
-            virtual ~Tetris(); //!< Destructor. Cleans up, if initialized.
-            
-            virtual void tick(float dt);
+            virtual ~Tetris(); //!< Destructor. Cleans up, if initialized.           
 
             virtual void start(void); //!< Starts the Tetris minigame.
             virtual void end(void); ///!< Ends the Tetris minigame.
 
+            virtual void tick(float dt);
+
             virtual void spawnPlayer(PlayerInfo* player); //!< Spawns the input player.
 
-            /**
-            @brief Set the TetrisCenterpoint (the playing field).
-            @param center A pointer to the TetrisCenterpoint to be set.
-            */
-            void setCenterpoint(TetrisCenterpoint* center)
-                { this->center_ = center; }
+            void setCenterpoint(TetrisCenterpoint* center);
 
             PlayerInfo* getPlayer(void) const; //!< Get the player.
+
+            bool isValidMove(TetrisStone* stone, const Vector3& position);
 
         protected:
             virtual void spawnPlayersIfRequested(); //!< Spawns player.
 
+        private:
             void startStone(void); //!< Starts with the first stone.
             void createStone(void);
             void cleanup(void); //!< Cleans up the Gametype by destroying the ball and the bats.
-            bool correctStonePos(TetrisStone* stone); //!< Check whether the supplied stone is in an allowed position
+            bool correctStonePos(TetrisStone* stone, const Vector3& position); //!< Check whether the supplied stone is in an allowed position
             
             PlayerInfo* player_;
@@ -86,4 +84,5 @@
             WeakPtr<TetrisCenterpoint> center_; //!< The playing field.
             std::vector<TetrisStone*> stones_; //!< A list of all stones in play.
+            std::vector< std::vector<bool> > grid_;
             TetrisStone* activeStone_;
             
Index: /code/branches/tetris/src/modules/tetris/TetrisCenterpoint.cc
===================================================================
--- /code/branches/tetris/src/modules/tetris/TetrisCenterpoint.cc	(revision 8536)
+++ /code/branches/tetris/src/modules/tetris/TetrisCenterpoint.cc	(revision 8537)
@@ -68,7 +68,7 @@
         SUPER(TetrisCenterpoint, XMLPort, xmlelement, mode);
 
-        XMLPortParam(TetrisCenterpoint, "width", setWidth, getWidth, xmlelement, mode);
-        XMLPortParam(TetrisCenterpoint, "height", setHeight, setWidth, xmlelement, mode);
-        XMLPortParam(TetrisCenterpoint, "stoneSize", setStoneSize, getStoneSize, xmlelement, mode);
+        XMLPortParam(TetrisCenterpoint, "width", setWidth, getWidth, xmlelement, mode); // die Breite
+        XMLPortParam(TetrisCenterpoint, "height", setHeight, setWidth, xmlelement, mode); // die Grösse
+        XMLPortParam(TetrisCenterpoint, "stoneSize", setStoneSize, getStoneSize, xmlelement, mode); 
         XMLPortParam(TetrisCenterpoint, "stoneTemplate", setStoneTemplate, getStoneTemplate, xmlelement, mode);
         XMLPortParam(TetrisCenterpoint, "stoneSpeed", setStoneSpeed, getStoneSpeed, xmlelement, mode);
Index: /code/branches/tetris/src/modules/tetris/TetrisStone.cc
===================================================================
--- /code/branches/tetris/src/modules/tetris/TetrisStone.cc	(revision 8536)
+++ /code/branches/tetris/src/modules/tetris/TetrisStone.cc	(revision 8537)
@@ -37,4 +37,6 @@
 #include "core/XMLPort.h"
 
+#include "Tetris.h"
+
 namespace orxonox
 {
@@ -52,4 +54,10 @@
         this->delay_ = false;
         this->delayTimer_.setTimer(0.2f, false, createExecutor(createFunctor(&TetrisStone::enableMovement, this)));
+        this->previousPosition_ = Vector3::ZERO;
+    }
+
+    void TetrisStone::tick(float dt)
+    {
+        SUPER(TetrisStone, tick, dt);
     }
 
@@ -76,5 +84,10 @@
         {
             const Vector3& position = this->getPosition();
-            this->setPosition(position.x+value.x/abs(value.x)*this->size_, position.y, position.z);
+            Vector3 newPos = Vector3(position.x+value.x/abs(value.x)*this->size_, position.y, position.z);
+            if(!this->tetris_->isValidMove(this, newPos))
+                return;
+
+            //this->previousPosition_ = position;
+            this->setPosition(newPos);
             this->delay_ = true;
             this->delayTimer_.startTimer();
Index: /code/branches/tetris/src/modules/tetris/TetrisStone.h
===================================================================
--- /code/branches/tetris/src/modules/tetris/TetrisStone.h	(revision 8536)
+++ /code/branches/tetris/src/modules/tetris/TetrisStone.h	(revision 8537)
@@ -57,4 +57,6 @@
             virtual ~TetrisStone() {}
 
+            virtual void tick(float dt);
+
             virtual void moveFrontBack(const Vector2& value); //!< Overloaded the function to steer the bat up and down.
             virtual void moveRightLeft(const Vector2& value); //!< Overloaded the function to steer the bat up and down.
@@ -75,4 +77,10 @@
                 { return this->size_; }
 
+            const Vector3& getPreviousPosition() const
+                { return this->previousPosition_; }
+
+            void setGame(Tetris* tetris)
+                { assert(tetris); tetris_ = tetris; }
+
         private:
             void enableMovement(void)
@@ -82,4 +90,7 @@
             bool delay_;
             Timer delayTimer_;
+
+            Vector3 previousPosition_;
+            Tetris* tetris_;
     };
 }
