Index: code/branches/3DPacman_FS18/src/modules/Pacman/3DPacman.cc
===================================================================
--- code/branches/3DPacman_FS18/src/modules/Pacman/3DPacman.cc	(revision 11844)
+++ code/branches/3DPacman_FS18/src/modules/Pacman/3DPacman.cc	(revision 11859)
@@ -34,4 +34,7 @@
 #include "3DPacman.h"
 #include "core/CoreIncludes.h"
+#include "PacmanGelb.h"
+#include "PacmanGhost.h"
+#include "PacmanPointSphere.h"
 
 namespace orxonox
@@ -43,99 +46,79 @@
         RegisterObject(3DPacman);
 
-        bEndGame = false;
-        lives = 1;
+        lives = 3;
+        point = 0:
         level = 1;
-        point = 0;
-        bShowLevel = false;
-        multiplier = 1;
-        b_combo = false;
-        counter = 5000;
-        pattern = 1;
-        lastPosition = 0;
-        // spawn enemy every 3.5 seconds
-        //enemySpawnTimer.setTimer(3.5f, true, createExecutor(createFunctor(&DodgeRace::spawnEnemy, this)));
-        comboTimer.setTimer(3.0f, true, createExecutor(createFunctor(&DodgeRace::comboControll, this)));
-        this->numberOfBots_ = 0; //sets number of default bots temporarly to 0
-        this->center_ = nullptr;
 
-        this->setHUDTemplate("DodgeRaceHUD");
     }
 
-    void DodgeRace::levelUp()
+    void 3DPacman::levelUp()
     {
-        level++;
-        if (getPlayer() != nullptr)
-        {
-            for (int i = 0; i < 7; i++)
-            {
-                WeakPtr<ExplosionPart> chunk5 = new ExplosionPart(this->center_->getContext());
-                chunk5->setPosition(Vector3(600, 0, 100.f * i - 300));
-                chunk5->setVelocity(Vector3(1000, 0, 0));  //player->getVelocity()
-                chunk5->setScale(10);
-                chunk5->setEffect1("Orxonox/explosion2b");
-                chunk5->setEffect2("Orxonox/smoke6");
-                chunk5->Explode();
-
-            }
-        }
-        addPoints(multiplier * 42);
-        multiplier *= 2;
-        toggleShowLevel();
-        showLevelTimer.setTimer(1.0f, false, createExecutor(createFunctor(&DodgeRace::toggleShowLevel, this)));
+        this->end();
     }
 
-    void DodgeRace::tick(float dt)
+
+    PacmanGhost[4] ghosts;
+    PacmanPointSphere[1] spheres;
+
+
+    void 3DPacman::tick(float dt)
     {
-        DodgeRaceShip* player = this->getPlayer();
+        int i = 0;
+        for(PacmanGhost* nextghost : ObjectList<PacmanGhost>()){
+            ghosts[i] = nextghost;
+            i++;
+        }
+
+        i = 0:
+        for(PacmanPointSphere* nextsphere : ObjectList<PacmanPointSphere>()){
+            spheres[i] = nextsphere;
+            i++;
+        }
+
+        player = this->getPlayer();
         if (player != nullptr)
         {
-            currentPosition = player->getWorldPosition().x;
-            counter = counter + (currentPosition - lastPosition);
-            lastPosition = currentPosition;
-            point = (int) currentPosition;
-            player->speed = 830.0f - (point / 1000);
+            currentPosition = player->getWorldPosition();
+        }
 
-            for(unsigned int i=0; i < cubeList.size();i++)
-            {
-                if(cubeList.at(i)->getPosition().x < currentPosition-3000)
-                {
-                    cubeList.at(i)->destroy();
-                    cubeList.erase(cubeList.begin()+i);
-                }
-            }
+        bool bcolli = false;
+        for(int nrghost = 0, (nrghost<3) && (!bcolli), ++nrghost){
+            bcolli = collis(ghosts[nrghost]->getPosition(), currentPosition)
+        }
+        if(collis){
+            this->catched();
+        }
 
-            if(counter >= 3000)
-            {
-                counter = 0;
-                for(int i = 0; i<6; i++)
-                {
-                    DodgeRaceCube* cube = new DodgeRaceCube(this->center_->getContext());
-                    cubeList.push_back(cube);
-                    switch(pattern)
-                    {
-                    case 1: cube->addTemplate("DodgeRaceCube01");
-                    break;
-                    case 2: cube->addTemplate("DodgeRaceCube02");
-                    break;
+        SUPER(3DPacman, tick, dt);
 
-                    }
-
-                    cube->setPosition(player->getWorldPosition() + Vector3(5000.0f, 0.0f, -3600.0f + (i*1200)));
-                    //stEntity->setScale3D(50,50,50);
-                }
+    }
 
 
-                pattern %= 2;
-                pattern ++;
 
-            }
-
-        }
-        SUPER(DodgeRace, tick, dt);
+    bool 3DPacman::collis(Vector3 one, Vector3 other){
+        if((abs(one.x-other.x)<0.1) && (abs(one.x-other.x)<0.1) && (abs(one.x-other.x)<0.1))
+            return true;
+        return false;
     }
 
-    DodgeRaceShip* DodgeRace::getPlayer()
+    void 3DPacman::catched(){
+        if(lives) this->end();
+        --lives;
+        this->posreset();
+    } 
+
+    void 3DPacman::posreset(){
+        int i = 0;
+        for(PacmanGhost* nextghost : ObjectList<PacmanGhost>()){
+            ghosts[i] = nextghost;
+            i++;
+        }
+        
+    }
+
+
+    PacmanGelb* 3DPacman::getPlayer()
     {
-        for (DodgeRaceShip* ship : ObjectList<DodgeRaceShip>())
+        for (PacmanGelb* ship : ObjectList<PacmanGelb>())
         {
             return ship;
@@ -144,44 +127,13 @@
     }
 
-    void DodgeRace::costLife()
-    {
-        //endGameTimer.setTimer(8.0f, false, createExecutor(createFunctor(&DodgeRace::end, this)));
-        lives = 0;
-    };
 
-    void DodgeRace::comboControll()
-    {
-        if (b_combo)
-            multiplier++;
-        // if no combo was performed before, reset multiplier
-        else
-            multiplier = 1;
-        b_combo = false;
-    }
-
-    void DodgeRace::start()
+    void 3DPacman::start()
     {
         orxout() << "start" << endl;
-        for(unsigned int i=0; i< cubeList.size();i++)
-        {
-            cubeList.at(i)->destroy();
-            cubeList.erase(cubeList.begin()+i);
-
-        }
-        cubeList.clear();
-        // Set variable to temporarily force the player to spawn.
-        this->bForceSpawn_ = false;
-
-        if (this->center_ == nullptr)  // abandon mission!
-        {
-            orxout(internal_error) << "DodgeRace: No Centerpoint specified." << endl;
-            GSLevel::startMainMenu();
-            return;
-        }
-        // Call start for the parent class.
+        
         Deathmatch::start();
     }
 
-    void DodgeRace::playerPreSpawn(PlayerInfo* player)
+    void 3DPacman::playerPreSpawn(PlayerInfo* player)
     {
         this->playerInfo_ = player;
@@ -190,30 +142,8 @@
             this->end();
         }
-
-        // Reset all the cubes
-        /*
-        orxout() << "prespawn" << endl;
-        for(int i=0; i< cubeList.size();i++)
-        {
-            cubeList.at(i)->destroy();
-            cubeList.erase(cubeList.begin()+i);
-        }
-        cubeList.clear();
-        lives = 1;
-        point = 0;
-        lastPosition = 0;
-        */
     }
 
-    void DodgeRace::addPoints(int numPoints)
-    {
-        if (!bEndGame)
-        {
-            point += numPoints * multiplier;
-            b_combo = true;
-        }
-    }
 
-    void DodgeRace::end()
+    void 3DPacman::end()
     {
         // DON'T CALL THIS!
@@ -224,5 +154,5 @@
         {
             int score = this->getPoints();
-            Highscore::getInstance().storeScore("Dodge Race", score, this->playerInfo_);
+            Highscore::getInstance().storeScore("3DPacman", score, this->playerInfo_);
         }
         GSLevel::startMainMenu();
