Index: code/branches/presentation2012merge/src/modules/tetris/CMakeLists.txt
===================================================================
--- code/branches/presentation2012merge/src/modules/tetris/CMakeLists.txt	(revision 9280)
+++ code/branches/presentation2012merge/src/modules/tetris/CMakeLists.txt	(revision 9286)
@@ -3,4 +3,6 @@
   TetrisCenterpoint.cc
   TetrisStone.cc
+  TetrisBrick.cc
+  TetrisScore.cc
 )
 
@@ -10,4 +12,5 @@
   LINK_LIBRARIES
     orxonox
+    overlays
   SOURCE_FILES ${TETRIS_SRC_FILES}
 )
Index: code/branches/presentation2012merge/src/modules/tetris/Tetris.cc
===================================================================
--- code/branches/presentation2012merge/src/modules/tetris/Tetris.cc	(revision 9280)
+++ code/branches/presentation2012merge/src/modules/tetris/Tetris.cc	(revision 9286)
@@ -23,6 +23,14 @@
  *      ...
  *   Co-authors:
- *      ...
- *
+ *      Johannes Ritz
+ *
+ *
+ *BUG c) destroying the old stones causes segfault -> WeakPointer as solution ?
+ *BUG d) wrong collision detection: sometimes stones "bounce off"
+ *
+ *
+ *TASK c) end the game in a nicer way
+ *TASK d) save the highscore
+ *TASK e) eye candy
  */
 
@@ -42,4 +50,5 @@
 #include "TetrisCenterpoint.h"
 #include "TetrisStone.h"
+#include "TetrisBrick.h"
 #include "infos/PlayerInfo.h"
 
@@ -52,4 +61,5 @@
     @brief
         Constructor. Registers and initializes the object.
+    @ingroup Tetris
     */
     Tetris::Tetris(BaseObject* creator) : Deathmatch(creator)
@@ -57,11 +67,14 @@
         RegisterObject(Tetris);
 
-        this->activeStone_ = NULL;
+        this->activeBrick_ = NULL;
 
         // Pre-set the timer, but don't start it yet.
-        this->starttimer_.setTimer(1.0, false, createExecutor(createFunctor(&Tetris::startStone, this)));
+        this->starttimer_.setTimer(1.0, false, createExecutor(createFunctor(&Tetris::startBrick, this)));
         this->starttimer_.stopTimer();
 
         this->player_ = NULL;
+        this->endGameCriteria_ = 0.0f;
+        this->setHUDTemplate("TetrisHUD");
+        this->futureBrick_ = NULL;
     }
 
@@ -82,4 +95,8 @@
     void Tetris::cleanup()
     {
+        /*for(int i = 0;i < this->stones_.size(); i++) //TODO: Why isn't there any code like this
+        {                                              // compensating the 'new' statement?
+            delete this->stones_[i];
+        }//*/
 
     }
@@ -89,11 +106,18 @@
         SUPER(Tetris, tick, dt);
 
-        if(this->activeStone_ != NULL)
-        {
-            if(!this->isValidStonePosition(this->activeStone_, this->activeStone_->getPosition()))
-            {
-                this->activeStone_->setVelocity(Vector3::ZERO);
-                this->createStone();
-                this->startStone();
+        if((this->activeBrick_ != NULL)&&(!this->hasEnded()))
+        {
+        	this->endGameCriteria_ += dt;
+            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->findFullRows();
+                if(this->endGameCriteria_ < 0.1f) //end game if two bricks are created within a 0.1s interval.
+                    this->end();
+                this->createBrick();
+                this->startBrick();
+                this->endGameCriteria_ = 0.0f;
             }
         }
@@ -123,4 +147,41 @@
     }
 
+    /**
+    @brief
+        Check for each stone in a brick if it is moved the right way.
+    */
+    bool Tetris::isValidMove(TetrisBrick* brick, const Vector3& position, bool isRotation = false)
+    {
+        assert(brick);
+
+        for (unsigned int i = 0; i < brick->getNumberOfStones(); i++ )
+        {
+            TetrisStone* stone = brick->getStone(i);
+            Vector3 stonePosition; //the current stone's offset to position
+            if(isRotation)
+            	stonePosition = rotateVector(stone->getPosition(), brick->getRotationCount()+1);
+            else
+                stonePosition = rotateVector(stone->getPosition(), brick->getRotationCount());
+
+            if(! this->isValidMove(stone, position + stonePosition ))
+            {
+                return false;
+            }
+
+            //catch illegal rotation (such that collisions with ground are not permitted)
+            if(isRotation)
+            {
+                if((position + stonePosition).y < this->center_->getStoneSize()/2.0f) //!< If the stone has reached the bottom of the level
+                {
+                    return false;
+                }
+            }
+        }
+        return true;
+
+    }
+
+
+
     bool Tetris::isValidStonePosition(TetrisStone* stone, const Vector3& position)
     {
@@ -130,12 +191,19 @@
         for(std::vector<TetrisStone*>::const_reverse_iterator it = this->stones_.rbegin(); it != this->stones_.rend(); ++it)
         {
-            if(stone == *it)
+            if(this->activeBrick_->contains(*it))//skip the moving brick' stones
                 continue;
-
+            //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
+
+            //filter out cases where the falling stone is already below a steady stone
+            if(position.y < currentStonePosition.y - this->center_->getStoneSize()/2.0f)
+                continue;
             if((position.x == currentStonePosition.x) && (position.y < currentStonePosition.y + this->center_->getStoneSize()))
             {
-                this->activeStone_->setPosition(Vector3(this->activeStone_->getPosition().x, currentStonePosition.y+this->center_->getStoneSize(), this->activeStone_->getPosition().z));
+                int y_offset = static_cast<int>((this->activeBrick_->getPosition().y-currentStonePosition.y+10)/10)*10 + currentStonePosition.y;
+                if(y_offset < 0) //filter out extreme cases (very rare bug)
+                	y_offset = 0;
+                this->activeBrick_->setPosition(Vector3(this->activeBrick_->getPosition().x, y_offset, this->activeBrick_->getPosition().z));
                 return false;
             }// This case applies if the stones overlap partially vertically
@@ -145,5 +213,8 @@
         if(position.y < this->center_->getStoneSize()/2.0f) //!< If the stone has reached the bottom of the level
         {
-            stone->setPosition(Vector3(stone->getPosition().x, this->center_->getStoneSize()/2.0f, stone->getPosition().z));
+        	int yOffset = stone->getPosition().y + 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));
             return false;
         }
@@ -151,4 +222,37 @@
         return true;
     }
+    /**
+     * @brief This function determines wether a brick touches another brick or the ground.
+     *
+     */
+    bool Tetris::isValidBrickPosition(TetrisBrick* brick, const Vector3& position)
+    {
+        assert(brick);
+
+        for (unsigned int i = 0; i < brick->getNumberOfStones(); i++ )
+        {
+            TetrisStone* stone = brick->getStone(i);
+            Vector3 stonePosition = rotateVector(stone->getPosition(), brick->getRotationCount());
+            if(! this->isValidStonePosition(stone, position + stonePosition) )
+                return false;
+        }
+        return true;
+    }
+
+    /**
+    @brief
+        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++)
+        {
+            temp = position.x;
+            position.x = -position.y;
+            position.y = temp;
+        }
+        return position;
+    }
 
     /**
@@ -160,6 +264,8 @@
         if (this->center_ != NULL) // There needs to be a TetrisCenterpoint, i.e. the area the game takes place.
         {
-            // Create the first stone.
-            this->createStone();
+            // Create the futureBrick_
+            this->createBrick();
+            // Create the first brick.
+            this->createBrick();
         }
         else // If no centerpoint was specified, an error is thrown and the level is exited.
@@ -190,4 +296,10 @@
     void Tetris::end()
     {
+        this->activeBrick_->setVelocity(Vector3::ZERO);
+        if(this->activeBrick_ != NULL)
+        {
+            this->player_->stopControl();
+        }
+
         this->cleanup();
 
@@ -225,9 +337,7 @@
     }
 
-    /**
-    @brief
-        Starts the first stone.
-    */
-    void Tetris::startStone(void)
+
+
+    void Tetris::startBrick(void)
     {
         if(this->player_ == NULL)
@@ -235,39 +345,48 @@
 
         unsigned int cameraIndex = 0;
-        if(this->activeStone_ != NULL)
+        if(this->activeBrick_ != NULL)
         {
             // Get camera settings
-            cameraIndex = this->activeStone_->getCurrentCameraIndex();
+            cameraIndex = this->activeBrick_->getCurrentCameraIndex();
             this->player_->stopControl();
         }
-        
-        // Make the last stone to be created the active stone.
-        this->activeStone_ = this->stones_.back();
-        
-        this->player_->startControl(this->activeStone_);
-        this->activeStone_->setVelocity(0.0f, -this->center_->getStoneSpeed(), 0.0f);
-        this->activeStone_->setCameraPosition(cameraIndex);
-    }
-
-    /**
-    @brief
-        Creates a new stone.
-    */
-    void Tetris::createStone(void)
-    {
-        // Create a new stone and add it to the list of stones.
-        TetrisStone* stone = new TetrisStone(this->center_);
-        this->stones_.push_back(stone);
-        
+
+        // Make the last brick to be created the active brick.
+        this->activeBrick_ = this->bricks_.back();
+
+        this->player_->startControl(this->activeBrick_);
+        this->activeBrick_->setVelocity(0.0f, -this->center_->getStoneSpeed(), 0.0f);
+        this->activeBrick_->setCameraPosition(cameraIndex);
+    }
+
+    void Tetris::createBrick(void)             //TODO: random rotation offset between 0 and 3 (times 90°)
+    {
+        // Use the futureBrick_ as new currentBrick by setting its position and storing it in this->bricks
+        if(this->futureBrick_ != NULL)
+        {
+            for (unsigned int i = 0; i < this->futureBrick_->getNumberOfStones(); i++)
+            {
+                this->stones_.push_back(this->futureBrick_->getStone(i));
+            }
+            float xPos = (this->center_->getWidth()/2 + ((this->center_->getWidth() % 2)*2-1)/2.0f)*this->center_->getStoneSize();
+            float yPos = (this->center_->getHeight()-0.5f)*this->center_->getStoneSize();
+            this->futureBrick_->setPosition(xPos, yPos, 0.0f);
+            this->bricks_.push_back(this->futureBrick_);
+        }
+        // create new futureBrick_
+        this->futureBrick_ = new TetrisBrick(this->center_);
+
+
         // Apply the stone template to the stone.
-        stone->addTemplate(this->center_->getStoneTemplate());
-        
-        // Attach the stone to the Centerpoint and set the position of the stone to be at the top middle.
-        this->center_->attach(stone);
-        float xPos = (this->center_->getWidth()/2 + ((this->center_->getWidth() % 2)*2-1)/2.0f)*this->center_->getStoneSize();
-        float yPos = (this->center_->getHeight()-0.5f)*this->center_->getStoneSize();
-        stone->setPosition(xPos, yPos, 0.0f);
-        stone->setGame(this);
-    }
+        this->futureBrick_->addTemplate(this->center_->getBrickTemplate());
+
+        // Attach the brick to the Centerpoint and set the position of the brick to be at the left side.
+        this->center_->attach(this->futureBrick_);
+        float xPos = (this->center_->getWidth()*1.6 + ((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);
+    }
+
 
     /**
@@ -282,4 +401,9 @@
     }
 
+    /*TetrisCenterpoint* Tetris::getCenterpoint(void) const
+    {
+        return this->center_;
+    }*/
+
     /**
     @brief Set the TetrisCenterpoint (the playing field).
@@ -291,3 +415,51 @@
     }
 
+    /**
+    @brief Check each row if it is full. Removes all full rows. Update
+    @brief Manages score.
+    */
+    void Tetris::findFullRows()
+    {
+    	unsigned int correctPosition = 0;
+    	unsigned int stonesPerRow = 0;
+    	for (unsigned int row = 0; row < this->center_->getHeight(); row++)
+    	{
+    	    stonesPerRow = 0;
+            for(std::vector<TetrisStone*>::iterator it = this->stones_.begin(); it != this->stones_.end(); ++it)
+            {
+            	correctPosition = static_cast<unsigned int>(((*it)->getPosition().y - 5)/this->center_->getStoneSize());
+                if(correctPosition == row)
+                {
+                    stonesPerRow++;
+                    if(stonesPerRow == this->center_->getWidth())
+                    {
+                        clearRow(row);
+                        row--; //the row counter has to be decreased in order to detect multiple rows!
+                        this->playerScored(this->player_);// add points
+                        //increase the stone's speed
+                        this->center_->setStoneSpeed(this->center_->getStoneSpeed()+1.0f);
+                    }
+                }
+            }
+        }
+    }
+
+    void Tetris::clearRow(unsigned int row)
+    {// clear the full row
+        for(std::vector<TetrisStone*>::iterator it = this->stones_.begin(); it != this->stones_.end(); ++it)
+        {
+            if(static_cast<unsigned int>(((*it)->getPosition().y - 5)/this->center_->getStoneSize()) == row)
+            	(*it)->setPosition(Vector3(-50,-50,100));
+            	//{(*it)->destroy(); this->stones_.erase(it); orxout()<< "destroy row "<<endl;}//experimental
+        }
+      // adjust height of stones above the deleted row //TODO: check if this could be a source of a bug.
+        for(std::vector<TetrisStone*>::iterator it2 = this->stones_.begin(); it2 != this->stones_.end(); ++it2)
+        {
+            if(static_cast<unsigned int>(((*it2)->getPosition().y - 5)/this->center_->getStoneSize()) > row)
+                (*it2)->setPosition((*it2)->getPosition()-Vector3(0,10,0));
+        }
+
+    }
+
+
 }
Index: code/branches/presentation2012merge/src/modules/tetris/Tetris.h
===================================================================
--- code/branches/presentation2012merge/src/modules/tetris/Tetris.h	(revision 9280)
+++ code/branches/presentation2012merge/src/modules/tetris/Tetris.h	(revision 9286)
@@ -68,24 +68,36 @@
 
             PlayerInfo* getPlayer(void) const; //!< Get the player.
+            WeakPtr<TetrisCenterpoint> getCenterpoint(void)
+                { return this->center_; }
 
             bool isValidMove(TetrisStone* stone, const Vector3& position);
+            bool isValidMove(TetrisBrick* brick, const Vector3& position, bool isRotation);
+            Vector3 rotateVector(Vector3 position, unsigned int amount);
 
         protected:
             virtual void spawnPlayersIfRequested(); //!< Spawns player.
 
+
         private:
-            void startStone(void); //!< Starts with the first stone.
-            void createStone(void);
+            void startBrick(void);
+            void createBrick(void);
             void cleanup(void); //!< Cleans up the Gametype by destroying the ball and the bats.
             bool isValidStonePosition(TetrisStone* stone, const Vector3& position);
+            bool isValidBrickPosition(TetrisBrick* brick, const Vector3& position);
+            void findFullRows(void);
+            void clearRow(unsigned int row);
+
             
             PlayerInfo* player_;
 
             WeakPtr<TetrisCenterpoint> center_; //!< The playing field.
+            std::vector<TetrisBrick*> bricks_; //!< A list of all bricks in play.
             std::vector<TetrisStone*> stones_; //!< A list of all stones in play.
             std::vector< std::vector<bool> > grid_;
-            TetrisStone* activeStone_;
+            TetrisBrick* activeBrick_;
+            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.
     };
 }
Index: code/branches/presentation2012merge/src/modules/tetris/TetrisBrick.cc
===================================================================
--- code/branches/presentation2012merge/src/modules/tetris/TetrisBrick.cc	(revision 9286)
+++ code/branches/presentation2012merge/src/modules/tetris/TetrisBrick.cc	(revision 9286)
@@ -0,0 +1,258 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      ...
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file TetrisBrick.cc
+    @brief Implementation of the TetrisBrick class.
+*/
+
+#include "TetrisBrick.h"
+
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+
+#include "TetrisCenterpoint.h"
+#include "TetrisStone.h"
+#include "Tetris.h"
+#include "util/Math.h"
+
+namespace orxonox
+{
+    CreateFactory(TetrisBrick);
+
+    /**
+    @brief
+        Constructor. Registers and initializes the object.
+    @ingroup Tetris
+    */
+    TetrisBrick::TetrisBrick(BaseObject* creator): ControllableEntity(creator)
+    {
+        RegisterObject(TetrisBrick);
+        this->shapeIndex_ = static_cast<unsigned int>(rnd(7.0f)); //<! 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)));
+        this->lockRotation_ = false;
+        this->tetris_ = this->getTetris();
+        this->size_ = 10.0f; //TODO: fix this via this->tetris_->center_->getStoneSize();
+        this->rotationCount_ = 0;
+        this->createBrick(); //<! create a whole new Brick;
+    }
+
+    /**
+    @brief
+        This function partly initializes a TetrisBrick as an array of TetrisStones
+    */
+    void TetrisBrick::createBrick(void)
+    { //Index 0 : single stone, 1 : 4 in a row; 2: 4-Block right shifted; 3: 'T' 4: 4-Block left shifted;
+      //Index 5 : 4-Block; 6 : 'L'; 7 : mirrored 'L';
+        if(this->shapeIndex_ == 0)
+            this->stonesPerBrick_ = 1;
+        for (unsigned int i = 0; i < this->stonesPerBrick_; i++)
+        {
+            // Create a new stone and add it to the brick.
+            TetrisStone* stone = new TetrisStone(this);
+            stone->setHealth(1.0f);
+            this->brickStones_.push_back(stone);
+            this->attach(stone);
+            this->formBrick(stone, i);
+            if(this->tetris_ != NULL)
+            {
+                stone->setGame(this->tetris_);
+                if(this->tetris_->getCenterpoint() != NULL)
+                    stone->addTemplate(this->tetris_->getCenterpoint()->getStoneTemplate());
+                else
+                	orxout()<< "tetris_->getCenterpoint == NULL in TetrisBrick.cc"<< endl;
+            }
+            else
+                orxout()<< "tetris_ == NULL in TetrisBrick.cc"<< endl;
+        }
+    }
+
+    /**
+    @brief
+        This function creates the shape of a TetrisBrick. ! Spaghetti-Code !
+    @param i
+        The stone's number.
+    @param stone
+        The TetrisStone that is placed relative to the brick's position.
+    */
+    void TetrisBrick::formBrick(TetrisStone* stone, unsigned int i)
+    {
+        if(i == 0) //setting the first stone as
+        {
+            stone->setPosition(0.0f, 0.0f, 0.0f);
+        }
+        else if(i == 1)
+        {
+            stone->setPosition(0.0f, size_, 0.0f);
+        }
+        else if(i == 2)
+        {
+            if(this->shapeIndex_ == 1 || this->shapeIndex_ == 6 || this->shapeIndex_ == 7)
+            {
+            	stone->setPosition(0.0f, 2*size_, 0.0f);
+            }
+            else if(this->shapeIndex_ == 3 || this->shapeIndex_ == 4|| this->shapeIndex_ == 5)
+            {
+            	stone->setPosition(size_, 0, 0.0f);
+            }
+            else if(this->shapeIndex_ == 2)
+            {
+            	stone->setPosition(-size_, 0, 0.0f);
+            }
+        }
+        else if(i == 3)
+        {
+            if(this->shapeIndex_ == 2 || this->shapeIndex_ == 5)
+            {
+            	stone->setPosition(size_, size_, 0.0f);
+            }
+            else if(this->shapeIndex_ == 1)
+            {
+            	stone->setPosition(0, 3*size_, 0.0f);
+            }
+            else if(this->shapeIndex_ == 3 || this->shapeIndex_ == 7)
+            {
+            	stone->setPosition(-size_, 0, 0.0f);
+            }
+            else if(this->shapeIndex_ == 4)
+            {
+            	stone->setPosition(-size_, size_, 0.0f);
+            }
+            else if(this->shapeIndex_ == 6)
+            {
+            	stone->setPosition(size_, 0, 0.0f);
+            }
+        }
+    }
+
+    bool TetrisBrick::isValidMove(const Vector3& position, bool isRotation = false)
+    {
+    	return this->tetris_->isValidMove(this,position, isRotation);
+    }
+
+    TetrisStone* TetrisBrick::getStone(unsigned int i)
+    {
+    	if(i < this->brickStones_.size())
+            return this->brickStones_[i];
+    	else return NULL;
+    }
+
+
+    Tetris* TetrisBrick::getTetris()
+    {
+        if (this->getGametype() != NULL && this->getGametype()->isA(Class(Tetris)))
+        {
+            Tetris* tetrisGametype = orxonox_cast<Tetris*>(this->getGametype().get());
+            return tetrisGametype;
+        }
+        return NULL;
+    }
+//TODO: refactor this function; is not needed if brickstones are added to Tetris::stones_ after collision.
+    bool TetrisBrick::contains(TetrisStone* stone)
+    {
+        for(unsigned int i = 0; i < brickStones_.size(); i++)
+        {
+            if(stone == brickStones_[i])
+                return true;
+        }
+        return false;
+    }
+
+    /**
+    @brief
+        Overloaded the function to rotate the Brick.
+    @param value
+        A vector whose first component is the angle by which to rotate.
+    */
+    void TetrisBrick::moveFrontBack(const Vector2& value)
+    {
+        if(value.x < 0) //speedup on key down
+        {
+            this->setVelocity(this->getVelocity()*1.1);
+        }
+        else if(!this->lockRotation_) //rotate when key up is pressed
+        {
+        	if(!isValidMove(this->getPosition(), true)) //catch illegal rotations
+        	    return;
+            this->lockRotation_ = true; // multiple calls of this function have to be filtered out.
+            this->rotationTimer_.setTimer(0.1f, false, createExecutor(createFunctor(&TetrisBrick::unlockRotation, this)));
+            Quaternion q(Degree(90), Vector3::UNIT_Z);
+            this->setOrientation(this->getOrientation()*q); //rotation: roll 90°
+            this->rotationCount_ = (this->rotationCount_ + 1) % 4;
+        }
+    }
+
+    /**
+    @brief
+        Overloaded the function to steer the Brick right and left
+    @param value
+        A vector whose first component is the direction in which we want to steer the Brick.
+    */
+    void TetrisBrick::moveRightLeft(const Vector2& value)
+    {
+        if(!this->delay_)
+        {
+            const Vector3& position = this->getPosition();
+            Vector3 newPos = Vector3(position.x+value.x/abs(value.x)*this->size_, position.y, position.z);
+            if(!this->isValidMove(newPos))
+                return;
+
+            this->setPosition(newPos);
+            this->delay_ = true;
+            this->delayTimer_.startTimer();
+        }
+    }
+
+    /**
+    @brief
+        Is called when the player changed.
+    */
+    void TetrisBrick::changedPlayer()
+    {
+        this->setVelocity(0.0f, 0.0f, 0.0f);
+    }
+
+    /**
+    @brief
+        Attaches stones to the Centerpoint.
+    */
+    void TetrisBrick::releaseStones(TetrisCenterpoint* center)
+    {
+        assert(this->tetris_);
+        for(unsigned int i = 0; i < brickStones_.size(); i++)
+        {
+            this->brickStones_[i]->detachFromParent();
+            this->brickStones_[i]->attachToParent(center);
+            this->brickStones_[i]->setPosition(this->getPosition()+this->tetris_->rotateVector(this->brickStones_[i]->getPosition(),this->rotationCount_ ));
+        }
+
+    }
+
+}
Index: code/branches/presentation2012merge/src/modules/tetris/TetrisBrick.h
===================================================================
--- code/branches/presentation2012merge/src/modules/tetris/TetrisBrick.h	(revision 9286)
+++ code/branches/presentation2012merge/src/modules/tetris/TetrisBrick.h	(revision 9286)
@@ -0,0 +1,107 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      ...
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file TetrisBrick.h
+    @brief Declaration of the TetrisBrick class.
+    @ingroup Tetris
+*/
+
+#ifndef _TetrisBrick_H__
+#define _TetrisBrick_H__
+
+#include "tetris/TetrisPrereqs.h"
+
+#include "worldentities/ControllableEntity.h"
+#include "tools/Timer.h"
+
+namespace orxonox
+{
+
+    /**
+    @brief
+        ContainerClass in order to create TetrisBricks by combining TetrisStones.
+    @author
+
+    @ingroup Tetris
+    */
+    class _TetrisExport TetrisBrick : public ControllableEntity
+    {
+        public:
+            TetrisBrick(BaseObject* creator); //!< Constructor. Registers and initializes the object.
+            virtual ~TetrisBrick() {}
+
+            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.
+            virtual void changedPlayer(); //!< Is called when the player changed.
+
+            bool isValidMove(const Vector3& position, bool isRotation);
+            unsigned int getNumberOfStones(void) const
+                { return this->brickStones_.size(); }
+            TetrisStone* getStone(unsigned int i);
+            bool contains(TetrisStone* stone);
+
+            void setGame(Tetris* tetris)
+                { assert(tetris); tetris_ = tetris; }
+            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);
+            Tetris* getTetris();
+
+            unsigned int shapeIndex_; //!< My way to represent the different brick shapes.
+            unsigned int stonesPerBrick_; //!< So many stones are contained in this brick.
+            std::vector<TetrisStone*> brickStones_; //!< A list of all stones in a brick.
+
+
+            void enableMovement(void)
+                { this->delay_ = false; }
+            void unlockRotation(void)
+                { this->lockRotation_ = false; }
+
+            float getSize(void) const
+                { return this->size_; }
+
+
+            float size_; //!< The dimensions a stone has in the game world. //TODO: get stone dimensions
+            bool delay_;
+            bool lockRotation_;
+
+            unsigned int rotationCount_; //!< Stores the bricks orientation
+            Timer delayTimer_;
+            Timer rotationTimer_; ///!< This timer is used to filter out multiple rotation inputs.
+            Tetris* tetris_; //<! The Tetris class is responsible to initialize this value.
+
+    };
+}
+
+#endif /* _TetrisBrick_H__ */
Index: code/branches/presentation2012merge/src/modules/tetris/TetrisCenterpoint.cc
===================================================================
--- code/branches/presentation2012merge/src/modules/tetris/TetrisCenterpoint.cc	(revision 9280)
+++ code/branches/presentation2012merge/src/modules/tetris/TetrisCenterpoint.cc	(revision 9286)
@@ -30,4 +30,5 @@
     @file TetrisCenterpoint.cc
     @brief Implementation of the TetrisCenterpoint class.
+    @ingroup Tetris
 */
 
@@ -55,4 +56,5 @@
         this->stoneSize_ = 10.0f;
         this->stoneTemplate_ = "";
+        this->brickTemplate_ = "";
         this->stoneSpeed_ = 20.0f;
         
@@ -69,7 +71,8 @@
 
         XMLPortParam(TetrisCenterpoint, "width", setWidth, getWidth, xmlelement, mode); // die Breite
-        XMLPortParam(TetrisCenterpoint, "height", setHeight, setWidth, xmlelement, mode); // die Grösse
+        XMLPortParam(TetrisCenterpoint, "height", setHeight, getHeight, xmlelement, mode); // die Grösse //was sollte das mit setWidth??
         XMLPortParam(TetrisCenterpoint, "stoneSize", setStoneSize, getStoneSize, xmlelement, mode); 
         XMLPortParam(TetrisCenterpoint, "stoneTemplate", setStoneTemplate, getStoneTemplate, xmlelement, mode);
+        XMLPortParam(TetrisCenterpoint, "brickTemplate", setBrickTemplate, getBrickTemplate, xmlelement, mode);
         XMLPortParam(TetrisCenterpoint, "stoneSpeed", setStoneSpeed, getStoneSpeed, xmlelement, mode);
     }
Index: code/branches/presentation2012merge/src/modules/tetris/TetrisCenterpoint.h
===================================================================
--- code/branches/presentation2012merge/src/modules/tetris/TetrisCenterpoint.h	(revision 9280)
+++ code/branches/presentation2012merge/src/modules/tetris/TetrisCenterpoint.h	(revision 9286)
@@ -45,5 +45,6 @@
 
 namespace orxonox
-{
+{//idea: add 2 triggers to the centerpoint (one to determine when a box would go above the centerpoint;
+//the other to find out when the lowest row is filled totally)
     
     /**
@@ -118,4 +119,17 @@
             
             /**
+            @brief Set the template for the bricks.
+            @param template The template name to be applied to each brick.
+            */
+            void setBrickTemplate(const std::string& templateName)
+                { this->brickTemplate_ = templateName; }
+            /**
+            @brief Get the template for the bricks.
+            @return Returns the template name to be applied to each brick.
+            */
+            const std::string& getBrickTemplate(void) const
+                { return this->brickTemplate_; }
+
+            /**
             @brief Set the speed of the stones.
             @param speed The speed to be set.
@@ -137,4 +151,5 @@
             float stoneSize_;
             std::string stoneTemplate_;
+            std::string brickTemplate_;
             float stoneSpeed_;
 
Index: code/branches/presentation2012merge/src/modules/tetris/TetrisPrereqs.h
===================================================================
--- code/branches/presentation2012merge/src/modules/tetris/TetrisPrereqs.h	(revision 9280)
+++ code/branches/presentation2012merge/src/modules/tetris/TetrisPrereqs.h	(revision 9286)
@@ -68,4 +68,6 @@
     class TetrisCenterpoint;
     class TetrisStone;
+    class TetrisBrick;
+    class TetrisScore;
 }
 
Index: code/branches/presentation2012merge/src/modules/tetris/TetrisScore.cc
===================================================================
--- code/branches/presentation2012merge/src/modules/tetris/TetrisScore.cc	(revision 9286)
+++ code/branches/presentation2012merge/src/modules/tetris/TetrisScore.cc	(revision 9286)
@@ -0,0 +1,124 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Johannes Ritz
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file TetrisScore.cc
+    @brief Implementation of the TetrisScore class.
+    @ingroup Tetris
+*/
+
+#include "TetrisScore.h"
+
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+#include "util/Convert.h"
+
+#include "infos/PlayerInfo.h"
+
+#include "Tetris.h"
+
+namespace orxonox
+{
+    CreateFactory(TetrisScore);
+
+    /**
+    @brief
+        Constructor. Registers and initializes the object.
+    @ingroup Tetris
+    */
+    TetrisScore::TetrisScore(BaseObject* creator) : OverlayText(creator)
+    {
+        RegisterObject(TetrisScore);
+
+        this->owner_ = 0;
+        this->player_ = NULL;
+    }
+
+    /**
+    @brief
+        Destructor.
+    */
+    TetrisScore::~TetrisScore()
+    {
+    }
+
+    /**
+    @brief
+        Method to create a TetrisScore through XML.
+    */
+    void TetrisScore::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+    {
+        SUPER(TetrisScore, XMLPort, xmlelement, mode);
+    }
+
+    /**
+    @brief
+        Is called each tick.
+        Creates and sets the caption to be displayed by the TetrisScore.
+    @param dt
+        The time that has elapsed since the last tick.
+    */
+    void TetrisScore::tick(float dt)
+    {
+        SUPER(TetrisScore, tick, dt);
+
+        // If the owner is set. The owner being a Tetris game.
+        if (this->owner_ != NULL)
+        {
+            std::string score("0");
+	        if(!this->owner_->hasEnded())
+            {
+                //get the player
+                player_ = this->owner_->getPlayer();
+            }
+
+            if(this->owner_->hasStarted())
+            {
+                // Save the name and score of each player as a string.
+                if (player_ != NULL)
+                    score = multi_cast<std::string>(this->owner_->getScore(player_));
+            }
+            this->setCaption(score);
+        }
+    }
+
+    /**
+    @brief
+        Is called when the owner changes.
+        Sets the owner to NULL, if it is not a pointer to a Tetris game.
+    */
+    void TetrisScore::changedOwner()
+    {
+        SUPER(TetrisScore, changedOwner);
+
+        if (this->getOwner() != NULL && this->getOwner()->getGametype())
+            this->owner_ = orxonox_cast<Tetris*>(this->getOwner()->getGametype().get());
+        else
+            this->owner_ = 0;
+    }
+}
Index: code/branches/presentation2012merge/src/modules/tetris/TetrisScore.h
===================================================================
--- code/branches/presentation2012merge/src/modules/tetris/TetrisScore.h	(revision 9286)
+++ code/branches/presentation2012merge/src/modules/tetris/TetrisScore.h	(revision 9286)
@@ -0,0 +1,71 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file TetrisScore.h
+    @brief Declaration of the TetrisScore class.
+    @ingroup Tetris
+*/
+
+#ifndef _TetrisScore_H__
+#define _TetrisScore_H__
+
+#include "tetris/TetrisPrereqs.h"
+
+#include "tools/interfaces/Tickable.h"
+
+#include "overlays/OverlayText.h"
+
+namespace orxonox
+{
+
+    /**
+    @brief
+        The TetrisScore class displays the score for a game of @ref orxonox::Tetris "Tetris".
+
+    @author
+        Johannes Ritz
+
+    @ingroup Tetris
+    */
+    class _TetrisExport TetrisScore : public OverlayText, public Tickable
+    {
+        public:
+            TetrisScore(BaseObject* creator);
+            virtual ~TetrisScore();
+
+            virtual void tick(float dt); //!< Creates and sets the caption to be displayed by the TetrisScore.
+            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+            virtual void changedOwner(); //!< Is called when the owner changes.
+
+        private:
+            Tetris* owner_; //!< The Tetris game that owns this TetrisScore.
+            PlayerInfo* player_; //!< Store information about the player permanently.
+    };
+}
+#endif /* _TetrisScore_H__ */
Index: code/branches/presentation2012merge/src/modules/tetris/TetrisStone.cc
===================================================================
--- code/branches/presentation2012merge/src/modules/tetris/TetrisStone.cc	(revision 9280)
+++ code/branches/presentation2012merge/src/modules/tetris/TetrisStone.cc	(revision 9286)
@@ -30,4 +30,5 @@
     @file TetrisStone.cc
     @brief Implementation of the TetrisStone class.
+    @ingroup Tetris
 */
 
@@ -47,11 +48,13 @@
         Constructor. Registers and initializes the object.
     */
-    TetrisStone::TetrisStone(BaseObject* creator) : ControllableEntity(creator)
+    TetrisStone::TetrisStone(BaseObject* creator) : Pawn(creator)
     {
         RegisterObject(TetrisStone);
-        
+
         this->size_ = 10.0f;
         this->delay_ = false;
         this->delayTimer_.setTimer(0.2f, false, createExecutor(createFunctor(&TetrisStone::enableMovement, this)));
+        this->lockRotation_ = false;
+
     }
 
@@ -64,7 +67,15 @@
     void TetrisStone::moveFrontBack(const Vector2& value)
     {
-        if(value.x < 0)
+        if(value.x < 0) //speedup on key down
         {
             this->setVelocity(this->getVelocity()*1.1);
+        }
+        else if(!this->lockRotation_) //rotate when key up is pressed
+        {
+            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);
+            this->setOrientation(this->getOrientation()*q); //rotation: roll 90°
+
         }
     }
Index: code/branches/presentation2012merge/src/modules/tetris/TetrisStone.h
===================================================================
--- code/branches/presentation2012merge/src/modules/tetris/TetrisStone.h	(revision 9280)
+++ code/branches/presentation2012merge/src/modules/tetris/TetrisStone.h	(revision 9286)
@@ -38,5 +38,5 @@
 #include "tetris/TetrisPrereqs.h"
 
-#include "worldentities/ControllableEntity.h"
+#include "worldentities/pawns/Pawn.h"
 #include "tools/Timer.h"
 
@@ -51,5 +51,5 @@
     @ingroup Tetris
     */
-    class _TetrisExport TetrisStone : public ControllableEntity
+    class _TetrisExport TetrisStone : public Pawn
     {
         public:
@@ -81,8 +81,12 @@
             void enableMovement(void)
                 { this->delay_ = false; }
-            
+            void unlockRotation(void)
+                { this->lockRotation_ = false; }
+
             float size_; //!< The dimensions a stone has in the game world.
             bool delay_;
+            bool lockRotation_;
             Timer delayTimer_;
+            Timer rotationTimer_; ///!< This timer is used to filter out multiple rotation inputs.
 
             Tetris* tetris_;
