Index: code/branches/towerdefenseFS15/src/modules/tetris/Tetris.h
===================================================================
--- code/branches/towerdefenseFS15/src/modules/tetris/Tetris.h	(revision 10397)
+++ code/branches/towerdefenseFS15/src/modules/tetris/Tetris.h	(revision 10406)
@@ -90,5 +90,4 @@
             void clearRow(unsigned int row);
 
-
             PlayerInfo* player_;
 
Index: code/branches/towerdefenseFS15/src/modules/towerdefense/TDCoordinate.cc
===================================================================
--- code/branches/towerdefenseFS15/src/modules/towerdefense/TDCoordinate.cc	(revision 10397)
+++ code/branches/towerdefenseFS15/src/modules/towerdefense/TDCoordinate.cc	(revision 10406)
@@ -17,13 +17,50 @@
     {
         //RegisterObject(TDCoordinate);
-        x=0;
-        y=0;
+        Set(0,0);
 
     }
 
     TDCoordinate::TDCoordinate(int x, int y)
-    {
-        this->x=x;
-        this->y=y;
+    {        
+        Set(x,y);
+    }
+
+    void TDCoordinate::Set(int x, int y)
+    {        
+        if (x < 0)
+        {
+            _x = 0;
+        }
+        else if (x > 15)
+        {
+            _x = 15;
+        }
+        else
+        {
+            _x = x;
+        }
+
+        if (y < 0)
+        {
+            _y = 0;
+        }
+        else if (y > 15)
+        {
+            _y = 15;
+        }
+        else
+        {
+            _y = y;
+        }
+    }
+
+    int TDCoordinate::GetX()
+    {        
+        return _x;
+    }
+
+    int TDCoordinate::GetY()
+    {        
+        return _y;
     }
 
@@ -34,6 +71,6 @@
 
         Vector3 *coord = new Vector3();
-        coord->x= (x-8) * tileScale;
-        coord->y= (y-8) * tileScale;
+        coord->x= (_x-8) * tileScale;
+        coord->y= (_y-8) * tileScale;
         coord->z=100;
 
Index: code/branches/towerdefenseFS15/src/modules/towerdefense/TDCoordinate.h
===================================================================
--- code/branches/towerdefenseFS15/src/modules/towerdefense/TDCoordinate.h	(revision 10397)
+++ code/branches/towerdefenseFS15/src/modules/towerdefense/TDCoordinate.h	(revision 10406)
@@ -16,14 +16,15 @@
     {
         public:
-            int x;
-            int y;
+            TDCoordinate();
+            TDCoordinate(int x, int y);
+            virtual ~TDCoordinate() {};
+            virtual void Set(int x, int y);
+            virtual int GetX();
+            virtual int GetY();
+            virtual Vector3 get3dcoordinate(); 
 
-            TDCoordinate();
-
-            Vector3 get3dcoordinate();
-
-            virtual ~TDCoordinate() {};
-
-            TDCoordinate(int x, int y);
+        private:
+            int _x;
+            int _y;
     };
 
Index: code/branches/towerdefenseFS15/src/modules/towerdefense/TowerDefense.cc
===================================================================
--- code/branches/towerdefenseFS15/src/modules/towerdefense/TowerDefense.cc	(revision 10397)
+++ code/branches/towerdefenseFS15/src/modules/towerdefense/TowerDefense.cc	(revision 10406)
@@ -35,5 +35,4 @@
  * pawnKilled() // wird aufgerufen, wenn ein Pawn stirbt (z.B: wenn )
  * playerScored() // kann man aufrufen um dem Spieler Punkte zu vergeben.
- *
  *
  *
@@ -110,6 +109,5 @@
 
         selecter = NULL;
-
-
+        this->player_ = NULL;        
         this->setHUDTemplate("TowerDefenseHUD");
         this->nextwaveTimer_.setTimer(10, false, createExecutor(createFunctor(&TowerDefense::nextwave, this)));
@@ -145,8 +143,22 @@
     void TowerDefense::start()
     {
+        if (center_ != NULL) // There needs to be a TowerDefenseCenterpoint, i.e. the area the game takes place.
+        {
+            if (selecter == NULL)
+            {
+                selecter = new TowerDefenseSelecter(this->center_->getContext());                
+            }
+            selecter->addTemplate(center_->getSelecterTemplate());
+            center_->attach(selecter);
+        }
+        else // If no centerpoint was specified, an error is thrown and the level is exited.
+        {
+            orxout(internal_error) << "Jump: No Centerpoint specified." << endl;
+            return;
+        }
 
         TeamDeathmatch::start();
 
-// Waypoints: [1,3] [10,3] [10,11] [13,11] -> add the points to a matrix so the player cant place towers on the path
+        // Waypoints: [1,3] [10,3] [10,11] [13,11] -> add the points to a matrix so the player cant place towers on the path
         for (int i=0; i < 16 ; i++)
         {
@@ -158,5 +170,15 @@
         }
 
-        selecter = new TowerDefenseSelecter(this->center_->getContext());
+        
+
+        if (player_ != NULL)
+        {
+            //this->player_->startControl(selecter);
+        }
+        else
+        {
+            orxout() << "player=NULL" << endl;
+        }
+
 
         Model* dummyModel = new Model(this->center_->getContext());
@@ -219,5 +241,5 @@
         en1->setTeam(2);
         en1->getController();
-        en1->setPosition(path.at(0)->get3dcoordinate());
+        en1->setPosition(path.at(0)->get3dcoordinate());        
         TowerDefenseEnemyvector.push_back(en1);
 
@@ -237,7 +259,35 @@
     }
 
+    void TowerDefense::spawnPlayer(PlayerInfo* player)
+    {
+        assert(player);
+        this->player_ = player;
+
+        if (selecter->getPlayer() == NULL)
+        {
+            this->player_ = player;
+            player->startControl(selecter);
+            players_[player].state_ = PlayerState::Alive;
+        } 
+    }
+
+    /**
+    @brief
+        Get the player.
+    @return
+        Returns a pointer to the player. If there is no player, NULL is returned.
+    */
+    PlayerInfo* TowerDefense::getPlayer(void) const
+    {
+        return this->player_;
+    }
+
     //not working yet
     void TowerDefense::upgradeTower(int x,int y)
     {
+        TDCoordinate* coord = new TDCoordinate(x,y);
+        x = coord->GetX();
+        y = coord->GetY();
+        
         const int upgradeCost = 20;
 
@@ -266,8 +316,12 @@
     /*adds Tower at Position (x,y) and reduces credit and adds the point to the towermatrix. template ("towerturret")
     so towers have ability if the turrets
-
     */
+
     void TowerDefense::addTower(int x, int y)
-    {
+    {        
+        TDCoordinate* coord = new TDCoordinate(x,y);
+        x = coord->GetX();
+        y = coord->GetY();
+
         const int towerCost = 20;
 
@@ -291,22 +345,20 @@
         int tileScale = (int) this->center_->getTileScale();
 
-        if (x > 15 || y > 15 || x < 0 || y < 0)
+        /*if (x > 15 || y > 15 || x < 0 || y < 0)
         {
             //Hard coded: TODO: let this depend on the centerpoint's height, width and fieldsize (fieldsize doesn't exist yet)
             orxout() << "Can not add Tower: x and y should be between 0 and 15" << endl;
             return;
-        }
-
-        orxout() << "Will add tower at (" << (x-8) * tileScale << "," << (y-8) * tileScale << ")" << endl;
-
+        }*/
+
+        //orxout() << "Will add tower at (" << (x-8) * tileScale << "," << (y-8) * tileScale << ")" << endl;
+        orxout() << "Will add tower at (" << x << "," << y << ")" << endl;
 
 
         //Create Model
-        Model* newtowermodel = new Model(this->center_->getContext());
-        newtowermodel->setMeshSource("Tower.mesh");
-        newtowermodel->setScale(45);
-        newtowermodel->setPosition(static_cast<float>((x-8) * tileScale), static_cast<float>((y-8) * tileScale), 50);
-
-
+        Model* newTowerModel = new Model(this->center_->getContext());
+        newTowerModel->setMeshSource("Tower.mesh");
+        newTowerModel->setScale(45);
+        newTowerModel->setPosition(static_cast<float>((x-8) * tileScale), static_cast<float>((y-8) * tileScale), 50);
 
         //Creates tower
@@ -318,7 +370,7 @@
         //Reduce credit
          this->buyTower(towerCost);
-         towerModelMatrix [x][y]= newtowermodel;
+         towerModelMatrix [x][y]= newTowerModel;
          towerTurretMatrix [x][y]= towernew;
-    }
+    }    
 
     bool TowerDefense::hasEnoughCreditForTower(int towerCost)
Index: code/branches/towerdefenseFS15/src/modules/towerdefense/TowerDefense.h
===================================================================
--- code/branches/towerdefenseFS15/src/modules/towerdefense/TowerDefense.h	(revision 10397)
+++ code/branches/towerdefenseFS15/src/modules/towerdefense/TowerDefense.h	(revision 10406)
@@ -45,4 +45,5 @@
 #include "core/object/WeakPtr.h"
 #include "TowerDefenseSelecter.h"
+#include "graphics/Camera.h"    
 
 
@@ -62,7 +63,6 @@
         virtual void end();
         virtual void tick(float dt);
-        //virtual void playerEntered(PlayerInfo* player);
-        //virtual bool playerLeft(PlayerInfo* player);
-        //Player Stats (set,get, reduce)
+        virtual void spawnPlayer(PlayerInfo* player);
+        PlayerInfo* getPlayer(void) const;
         int getCredit(){ return this->credit_; }
         int getLifes(){ return this->lifes_; }
@@ -75,5 +75,4 @@
         void nextwave(){ TowerDefenseEnemyvector.clear(); waves_++; time=0;}
         int reduceLifes(int NumberofLifes){ return lifes_-=NumberofLifes; }
-        TDCoordinate* selectedPos;
         TowerDefenseSelecter* selecter;
 
@@ -89,5 +88,4 @@
         /* Adds a tower at x, y in the playfield */
         void addTower(int x, int y);
-
         void upgradeTower(int x, int y);
 
@@ -99,4 +97,5 @@
     private:
         TowerDefenseCenterpoint *center_;
+        PlayerInfo* player_;
         float time;
 //        float time2;
@@ -109,8 +108,4 @@
         bool hasEnoughCreditForTower(int towerCost);
         bool hasEnoughCreditForUpgrade();
-
-
-
-        std::vector<TowerTurret*> towers_;
     };
 }
Index: code/branches/towerdefenseFS15/src/modules/towerdefense/TowerDefenseCenterpoint.cc
===================================================================
--- code/branches/towerdefenseFS15/src/modules/towerdefense/TowerDefenseCenterpoint.cc	(revision 10397)
+++ code/branches/towerdefenseFS15/src/modules/towerdefense/TowerDefenseCenterpoint.cc	(revision 10406)
@@ -71,4 +71,5 @@
         XMLPortParam(TowerDefenseCenterpoint, "height", setHeight, getHeight, xmlelement, mode);
         XMLPortParam(TowerDefenseCenterpoint, "tileScale", setTileScale, getTileScale, xmlelement, mode);
+        XMLPortParam(TowerDefenseCenterpoint, "selecterTemplate", setSelecterTemplate, getSelecterTemplate, xmlelement, mode);
 
         //TODO: add XMLPortObject(TowerDefenseCenterpoint, WorldEntity, "waypoints", addWaypoint, getWaypoint,  xmlelement, mode);
Index: code/branches/towerdefenseFS15/src/modules/towerdefense/TowerDefenseCenterpoint.h
===================================================================
--- code/branches/towerdefenseFS15/src/modules/towerdefense/TowerDefenseCenterpoint.h	(revision 10397)
+++ code/branches/towerdefenseFS15/src/modules/towerdefense/TowerDefenseCenterpoint.h	(revision 10406)
@@ -60,14 +60,14 @@
             void setWidth(unsigned int width)
                 { this->width_ = width; }
-
             unsigned int getWidth(void) const
                 { return this->width_; }
-
             void setHeight(unsigned int height)
                 { this->height_ = height; }
-
             unsigned int getHeight(void) const
                 { return this->height_; }
-
+            void setSelecterTemplate(const std::string& newTemplate)
+                { this->selecterTemplate_ = newTemplate; }
+            const std::string& getSelecterTemplate() const
+                { return this->selecterTemplate_; }   
             /**
                 @brief How to convert to world coordinates, e.g. that 0,15 is not at -8,-8 but at -80,-80 (if scale would be 10)
@@ -82,4 +82,5 @@
             void checkGametype();
 
+            std::string selecterTemplate_;
             unsigned int width_;
             unsigned int height_;
Index: code/branches/towerdefenseFS15/src/modules/towerdefense/TowerDefenseSelecter.cc
===================================================================
--- code/branches/towerdefenseFS15/src/modules/towerdefense/TowerDefenseSelecter.cc	(revision 10397)
+++ code/branches/towerdefenseFS15/src/modules/towerdefense/TowerDefenseSelecter.cc	(revision 10406)
@@ -51,10 +51,5 @@
         moveLeftPressed_ = false;
         moveRightPressed_ = false;
-        selectedPos_ = new TDCoordinate(0,0);
-
-        Model* selecterModel = new Model(context);
-        selecterModel->setMeshSource("cube.mesh");
-        selecterModel->setScale(45);
-
+        setSelectedPosition(0,0);     
     }
 
@@ -67,6 +62,4 @@
     {
         SUPER(TowerDefenseSelecter, XMLPort, xmlelement, mode);
-        // Beispielport // XMLPortParam(TowerDefenseSelecter, "mouseFactor", setMouseFactor, getMouseFactor, xmlelement, mode);
-
     }
 
@@ -77,58 +70,32 @@
         if (hasLocalController())
         {
+            int selecterPosX = selectedPos_->GetX();
+            int selecterPosY = selectedPos_->GetY();
 
             if (moveUpPressed_ == true)
             {
-                if(this->selectedPos_->y >= 15)
-                {
-                }
-                else
-                {
-                	this->selectedPos_->y +=1;
-                	this->setPosition(selectedPos_->get3dcoordinate());
-                }
-
+                selectedPos_->Set(selecterPosX, selecterPosY + 1);
+                updatePosition();
+                orxout() << "up" << endl;
             }
             if (moveDownPressed_ == true)
             {
-            	if(this->selectedPos_->y <= 0)
-            	{
-				}
-				else
-				{
-					this->selectedPos_->y -= 1;
-					this->setPosition(selectedPos_->get3dcoordinate());
-				}
-
-            	moveDownPressed_ = false;
+            	selectedPos_->Set(selecterPosX, selecterPosY - 1);
+                updatePosition();
+                orxout() << "Down" << endl;
             }
 
             if (moveLeftPressed_ == true)
             {
-                if(this->selectedPos_->x <= 0)
-                {
-                }
-                else
-                {
-                	this->selectedPos_->x -=1;
-                	this->setPosition(selectedPos_->get3dcoordinate());
-                }
-
+                selectedPos_->Set(selecterPosX - 1, selecterPosY);
+                updatePosition();
+                orxout() << "Left" << endl;
             }
             if (moveRightPressed_ == true)
             {
-            	if(this->selectedPos_->x >= 15)
-            	{
-				}
-				else
-				{
-					this->selectedPos_->x += 1;
-					this->setPosition(selectedPos_->get3dcoordinate());
-				}
-
-            	moveDownPressed_ = false;
+            	selectedPos_->Set(selecterPosX + 1, selecterPosY);
+                updatePosition();
+                orxout() << "Right" << endl;
             }
-
-
 
             /*
@@ -137,5 +104,4 @@
                 firePressed_ = false;
                 timeSinceLastFire_ = 0.0;
-                fireSignal_ = true;
             }
             */
@@ -146,5 +112,5 @@
         moveDownPressed_ = false;
         moveLeftPressed_ = false;
-        moveDownPressed_ = false;
+        moveRightPressed_ = false;
         //firePressed_ = false;
     }
@@ -199,3 +165,21 @@
         //firePressed_ = true;
     }
+
+    void TowerDefenseSelecter::updatePosition()
+    {
+        setPosition(selectedPos_->get3dcoordinate());
+    }
+
+    void TowerDefenseSelecter::setSelectedPosition(TDCoordinate* newPos)
+    {
+        selectedPos_ = newPos;
+        updatePosition();
+    }
+
+    void TowerDefenseSelecter::setSelectedPosition(int x,  int y)
+    {
+        setSelectedPosition(new TDCoordinate(x,y));
+    }
+
+
 }
Index: code/branches/towerdefenseFS15/src/modules/towerdefense/TowerDefenseSelecter.h
===================================================================
--- code/branches/towerdefenseFS15/src/modules/towerdefense/TowerDefenseSelecter.h	(revision 10397)
+++ code/branches/towerdefenseFS15/src/modules/towerdefense/TowerDefenseSelecter.h	(revision 10406)
@@ -41,6 +41,6 @@
             TowerDefenseSelecter(Context* context); //!< Constructor. Registers and initializes the object.
             virtual ~TowerDefenseSelecter();
-            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
-            virtual void tick(float dt);
+            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);         
+            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.
@@ -50,14 +50,15 @@
             void fire(unsigned int firemode);
             virtual void fired(unsigned int firemode);
+            virtual void setSelectedPosition(TDCoordinate* newPos);
+            virtual void setSelectedPosition(int x, int y);
+
+        private:            
+            virtual void updatePosition();
+            
             TDCoordinate* selectedPos_;
-
-
-
-        private:
-
             bool moveUpPressed_;
             bool moveDownPressed_;
             bool moveLeftPressed_;
-            bool moveRightPressed_;
+            bool moveRightPressed_;            
     };
 }
