Index: /code/branches/minigame4DHS14/src/modules/mini4Dgame/Mini4Dgame.cc
===================================================================
--- /code/branches/minigame4DHS14/src/modules/mini4Dgame/Mini4Dgame.cc	(revision 10097)
+++ /code/branches/minigame4DHS14/src/modules/mini4Dgame/Mini4Dgame.cc	(revision 10097)
@@ -0,0 +1,315 @@
+/*
+ *   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:
+ *      Johannes Ritz
+ *
+ *
+ *
+ *
+ *TASK c) end the game in a nicer way
+ *TASK d) save the highscore
+ *TASK e) eye candy
+ */
+
+/**
+    @file Tetris.cc
+    @brief Implementation of the Mini4Dgame class.
+*/
+
+#include "Mini4Dgame.h"
+
+#include "core/CoreIncludes.h"
+#include "core/command/Executor.h"
+#include "core/config/ConfigValueIncludes.h"
+
+#include "gamestates/GSLevel.h"
+#include "chat/ChatManager.h"
+
+#include "Mini4DgameCenterpoint.h"
+
+namespace orxonox
+{
+
+    RegisterUnloadableClass(Mini4Dgame);
+
+    /**
+    @brief
+        Constructor. Registers and initializes the object.
+    */
+    Mini4Dgame::Mini4Dgame(Context* context) : Deathmatch(context)
+    {
+        RegisterObject(Mini4Dgame);
+
+        this->center_ = 0;
+        this->player_[0] = NULL;
+        this->player_[1] = NULL;
+    }
+
+    /**
+    @brief
+        Destructor. Cleans up, if initialized.
+    */
+    Mini4Dgame::~Mini4Dgame()
+    {
+        if (this->isInitialized())
+            this->cleanup();
+    }
+
+    /**
+    @brief
+        Cleans up the Gametype.
+    */
+    void Mini4Dgame::cleanup()
+    {
+
+    }
+
+    /*
+    bool Mini4Dgame::isValidMove(Vector4* move, const Mini4DgameBoard* board)
+    {
+
+    }
+    */
+
+
+    /**
+    @brief
+        Starts the Tetris minigame.
+    */
+    void Mini4Dgame::start()
+    {
+        if (this->center_ != NULL) // There needs to be a Mini4DgameCenterpoint, i.e. the area the game takes place.
+        {
+            //TODO: create all objects if they don't exist so far and attach the parameters specified in the centerpoint to them
+        }
+        else // If no centerpoint was specified, an error is thrown and the level is exited.
+        {
+            orxout(internal_error) << "Mini4Dgame: No Centerpoint specified." << endl;
+            GSLevel::startMainMenu();
+            return;
+        }
+
+        // Set variable to temporarily force the player to spawn.
+        bool temp = this->bForceSpawn_;
+        this->bForceSpawn_ = true;
+
+        // Call start for the parent class.
+        Deathmatch::start();
+
+        // Reset the variable.
+        this->bForceSpawn_ = temp;
+    }
+
+    /**
+    @brief
+        Ends the Mini4Dgame minigame.
+    */
+    void Mini4Dgame::end()
+    {
+    	this->cleanup();
+
+        // Call end for the parent class.
+        Deathmatch::end();
+    }
+
+---------------------------------------------------------------------------------------------------------------------------------
+
+    /**
+    @brief
+        Spawns player.
+    */
+    void Mini4Dgame::spawnPlayersIfRequested()
+    {
+        // Spawn a human player.
+        for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
+            if (it->first->isHumanPlayer() && (it->first->isReadyToSpawn() || this->bForceSpawn_))
+                this->spawnPlayer(it->first);
+    }
+    
+    bool Tetris::playerLeft(PlayerInfo* player)
+    {
+        bool left = Gametype::playerLeft(player);
+        if(player && player->isHumanPlayer())
+        {
+            if(this->activeBrick_ != NULL)
+            {
+                this->player_->stopControl();
+            }
+            this->cleanup();
+        }
+        return left;
+    }
+
+    /**
+    @brief
+        Spawns the input player.
+    @param player
+        The player to be spawned.
+    */
+    void Tetris::spawnPlayer(PlayerInfo* player)
+    {
+        assert(player);
+
+        if(this->player_ == NULL)
+        {
+            this->player_ = player;
+            this->players_[player].state_ = PlayerState::Alive;
+        }
+    }
+
+
+
+    void Tetris::startBrick(void)
+    {
+        if(this->player_ == NULL)
+            return;
+
+        unsigned int cameraIndex = 0;
+        if(this->activeBrick_ != NULL)
+        {
+            // Get camera settings
+            cameraIndex = this->activeBrick_->getCurrentCameraIndex();
+            this->player_->stopControl();
+            // destroy old active brick
+            this->activeBrick_->destroy();
+        }
+
+        // Make the last brick to be created the active brick.
+        this->activeBrick_ = this->futureBrick_;
+        this->futureBrick_ = 0;
+
+        // set its position
+        this->player_->startControl(this->activeBrick_);
+        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->activeBrick_->setPosition(xPos, yPos, 0.0f);
+        this->activeBrick_->setVelocity(0.0f, -this->center_->getStoneSpeed(), 0.0f);
+        this->activeBrick_->setCameraPosition(cameraIndex);
+
+        // 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°)
+    {
+        // create new futureBrick_
+        this->futureBrick_ = new TetrisBrick(this->center_->getContext());
+
+
+        // Apply the stone template to the stone.
+        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.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);
+    }
+
+
+    /**
+    @brief
+        Get the player.
+    @return
+        Returns a pointer to the player. If there is no player, NULL is returned.
+    */
+    PlayerInfo* Tetris::getPlayer(void) const
+    {
+        return this->player_;
+    }
+
+    /*TetrisCenterpoint* Tetris::getCenterpoint(void) const
+    {
+        return this->center_;
+    }*/
+
+    /**
+    @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;
+    }
+
+    /**
+    @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::list<SmartPtr<TetrisStone> >::iterator it = this->stones_.begin(); it != this->stones_.end(); )
+            {
+                std::list<SmartPtr<TetrisStone> >::iterator it_temp = it++;
+                correctPosition = static_cast<unsigned int>(((*it_temp)->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::list<SmartPtr<TetrisStone> >::iterator it = this->stones_.begin(); it != this->stones_.end(); )
+        {
+            if(static_cast<unsigned int>(((*it)->getPosition().y - 5)/this->center_->getStoneSize()) == row)
+            {
+                (*it)->destroy();
+                this->stones_.erase(it++);
+            }
+            else
+                ++it;
+        }
+      // adjust height of stones above the deleted row //TODO: check if this could be a source of a bug.
+        for(std::list<SmartPtr<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((*it)->getPosition()-Vector3(0,10,0));
+        }
+
+    }
+
+
+}
Index: /code/branches/minigame4DHS14/src/modules/mini4Dgame/Mini4Dgame.h
===================================================================
--- /code/branches/minigame4DHS14/src/modules/mini4Dgame/Mini4Dgame.h	(revision 10097)
+++ /code/branches/minigame4DHS14/src/modules/mini4Dgame/Mini4Dgame.h	(revision 10097)
@@ -0,0 +1,84 @@
+/*
+ *   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 Mini4Dgame.h
+    @brief Declaration of the Mini4Dgame class.
+*/
+
+#ifndef _Mini4Dgame_H__
+#define _Mini4Dgame_H__
+
+#include "gametypes/Deathmatch.h"
+
+namespace orxonox
+{
+
+    /**
+    @brief
+
+    @author
+
+    */
+    class Mini4Dgame : public Deathmatch
+    {
+        public:
+    		Mini4Dgame(Context* context); //!< Constructor. Registers and initializes the object.
+            virtual ~Mini4Dgame(); //!< Destructor. Cleans up, if initialized.
+
+            virtual void start(void); //!< Starts the Mini4Dgame minigame.
+            virtual void end(void); ///!< Ends the Mini4Dgame minigame.
+
+            virtual void spawnPlayer(PlayerInfo* player); //!< Spawns the input player.
+            virtual bool playerLeft(PlayerInfo* player);
+
+            void setCenterpoint(Mini4DgameCenterpoint* center)
+            	{ this->center_ = center; }
+
+            PlayerInfo* getLeftPlayer() const; //!< Get the left player.
+            PlayerInfo* getRightPlayer() const; //!< Get the right player.
+
+
+            //bool isValidMove(Vector4* move, const Mini4DgameBoard* board);//!< Checks if the move is valid
+
+        protected:
+            virtual void spawnPlayersIfRequested(); //!< Spawns player.
+
+
+        private:
+            void cleanup(void); //!< Cleans up the Gametype by destroying the ball and the bats.
+
+            PlayerInfo* player_[2];//!< The two players
+
+            WeakPtr<Mini4DgameCenterpoint> center_; //!< The playing field.
+
+            //TODO: Board is missing up to now
+    };
+}
+
+#endif /* _Mini4Dgame_H__ */
Index: /code/branches/minigame4DHS14/src/modules/mini4Dgame/Mini4DgameCenterpoint.cc
===================================================================
--- /code/branches/minigame4DHS14/src/modules/mini4Dgame/Mini4DgameCenterpoint.cc	(revision 10097)
+++ /code/branches/minigame4DHS14/src/modules/mini4Dgame/Mini4DgameCenterpoint.cc	(revision 10097)
@@ -0,0 +1,95 @@
+/*
+ *   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 Mini4DgameCenterpoint.cc
+    @brief Implementation of the Mini4DgameCenterpoint class.
+*/
+
+#include "Mini4DgameCenterpoint.h"
+
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+
+#include "Mini4Dgame.h"
+
+namespace orxonox
+{
+    RegisterClass(Mini4DgameCenterpoint);
+
+    /**
+    @brief
+        Constructor. Registers and initializes the object and checks whether the gametype is actually Mini4Dgame.
+    */
+    Mini4DgameCenterpoint::Mini4DgameCenterpoint(Context* context) : StaticEntity(context)
+    {
+        RegisterObject(Mini4DgameCenterpoint);
+
+        this->width_ = 200;
+        this->height_ = 200;
+        this->length_ = 200;
+
+        this->checkGametype();
+    }
+
+    /**
+    @brief
+        Method to create a Mini4DgameCenterpoint through XML.
+    */
+    void Mini4DgameCenterpoint::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+    {
+        SUPER(Mini4DgameCenterpoint, XMLPort, xmlelement, mode);
+
+        XMLPortParam(Mini4DgameCenterpoint, "dimension", setFieldDimension, getFieldDimension, xmlelement, mode);
+    }
+
+    /**
+    @brief
+        Is called when the gametype has changed.
+    */
+    void Mini4DgameCenterpoint::changedGametype()
+    {
+        SUPER(Mini4DgameCenterpoint, changedGametype);
+
+        // Check, whether it's still Mini4Dgame.
+        this->checkGametype();
+    }
+
+    /**
+    @brief
+        Checks whether the gametype is Mini4Dgame and if it is, sets its centerpoint.
+    */
+    void Mini4DgameCenterpoint::checkGametype()
+    {
+        if (this->getGametype() != NULL && this->getGametype()->isA(Class(Mini4Dgame)))
+        {
+            Mini4Dgame* Mini4DgameGametype = orxonox_cast<Mini4Dgame*>(this->getGametype().get());
+            Mini4DgameGametype->setCenterpoint(this);
+        }
+    }
+}
Index: /code/branches/minigame4DHS14/src/modules/mini4Dgame/Mini4DgameCenterpoint.h
===================================================================
--- /code/branches/minigame4DHS14/src/modules/mini4Dgame/Mini4DgameCenterpoint.h	(revision 10097)
+++ /code/branches/minigame4DHS14/src/modules/mini4Dgame/Mini4DgameCenterpoint.h	(revision 10097)
@@ -0,0 +1,119 @@
+/*
+ *   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 Mini4DgameCenterpoint.h
+    @brief Declaration of the Mini4DgameCenterpoint class.
+*/
+
+#ifndef _Mini4DgameCenterpoint_H__
+#define _Mini4DgameCenterpoint_H__
+
+#include <string>
+
+#include <util/Math.h>
+
+#include "worldentities/StaticEntity.h"
+
+namespace orxonox
+{
+    
+    /**
+    @brief
+        The Mini4DgameCenterpoint implements the playing field @ref orxonox::Mini4Dgame "Mini4Dgame" takes place in and allows for many parameters of the minigame to be set.
+        
+        Various parameters can be set:
+        - The <b>dimension</b> is a vector, that defines the width and height of the playing field. The default is <em>(200, 120)</em>.
+        - The <b>balltemplate</b> is a template that is applied to the @ref orxonox::PongBall "PongBall", it can be used to attach different things to it, e.g. its @ref orxonox::Model "Model". See below for a usage example.
+        - The <b>battemplate</b> is a template that is applied to the @ref orxonox::PongBall "PongBat", it can be used to attach different things to it, e.g. its @ref orxonox::Model "Model". See below for a usage example.
+        - The <b>ballspeed</b> is the speed with which the @ref orxonox::PongBall "PongBall" moves. The default is <em>100</em>.
+        - The <b>ballaccfactor</b> is the acceleration factor for the @ref orxonox::PongBall "PongBall". The default is <em>1.0</em>.
+        - The <b>batspeed</b> is the speed with which the @ref orxonox::PongBat "PongBats" move. The default is <em>60</em>.
+        - The <b>batlength</b> is the length of the @ref orxonox::PongBat "PongBats" as the percentage of the height of the playing field. The default is <em>0.25</em>.
+    */
+    class Mini4DgameCenterpoint : public StaticEntity
+    {
+        public:
+            Mini4DgameCenterpoint(Context* context); //!< Constructor. Registers and initializes the object and checks whether the gametype is actually Mini4Dgame.
+            virtual ~Mini4DgameCenterpoint() {}
+
+            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method to create a Mini4DgameCenterpoint through XML.
+
+            virtual void changedGametype(); //!< Is called when the gametype has changed.
+
+            /**
+            @brief Set the template for the ball. (e.g. to attach the model of the ball, but also to attach an EventListener to it to detect, when it hits the boundaries, and e.g. display some ParticleEffets, when it does.)
+            @param balltemplate The name of the template to be set.
+
+            void setBalltemplate(const std::string& balltemplate)
+                { this->balltemplate_ = balltemplate; }
+            */
+
+            /**
+            @brief Get the template of the ball.
+            @return Returns the name of the template of the ball. 
+
+            const std::string& getBalltemplate() const
+                { return this->balltemplate_; }
+            */
+
+            /**
+            @brief Set the template for the bats. (e.g. to attach the model of the bat, but also to attach CameraPositions to it, to be able to view the game from the bats perspective)
+            @param battemplate The name of the template to be set.
+
+            void setBattemplate(const std::string& battemplate)
+                { this->battemplate_ = battemplate; }
+            */
+
+            /**
+            @brief Set the dimensions of the playing field.
+            @param dimension A vector with the width of the playing field as first component, the height as second and the length as third.
+            */
+            void setFieldDimension(const Vector3& dimension)
+                { this->width_ = dimension.x; this->height_ = dimension.y; this->length_ = dimension.z;}
+            /**
+            @brief Get the dimensions of the playing field.
+            @return Returns a vector with the width of the playing field as first component, the height as second and the length as third.
+            */
+            Vector3 getFieldDimension() const
+                { return Vector3(this->width_, this->height_, this->length_); }
+
+
+        private:
+            void checkGametype(); //!< Checks whether the gametype is Mini4Dgame and if it is, sets its centerpoint.
+
+            //std::string balltemplate_; //!< The template for the ball.
+            //std::string battemplate_; //!< The template for the bats.
+
+            float width_; //!< The height of the playing field.
+            float height_; //!< The width of the playing field.
+            float length_; //!< The length of the playing field.
+    };
+}
+
+#endif /* _Mini4DgameCenterpoint_H__ */
