[Orxonox-commit 7298] r11915 - in code/branches/3DPacman_FS18: data/levels src/modules/pacman

dreherm at orxonox.net dreherm at orxonox.net
Thu Apr 26 16:11:20 CEST 2018


Author: dreherm
Date: 2018-04-26 16:11:19 +0200 (Thu, 26 Apr 2018)
New Revision: 11915

Modified:
   code/branches/3DPacman_FS18/data/levels/3DPacman.oxw
   code/branches/3DPacman_FS18/src/modules/pacman/CMakeLists.txt
   code/branches/3DPacman_FS18/src/modules/pacman/Pacman.cc
   code/branches/3DPacman_FS18/src/modules/pacman/Pacman.h
   code/branches/3DPacman_FS18/src/modules/pacman/PacmanGhost.cc
   code/branches/3DPacman_FS18/src/modules/pacman/PacmanPointSphere.cc
   code/branches/3DPacman_FS18/src/modules/pacman/PacmanPointSphere.h
Log:
Game playable

Modified: code/branches/3DPacman_FS18/data/levels/3DPacman.oxw
===================================================================
--- code/branches/3DPacman_FS18/data/levels/3DPacman.oxw	2018-04-26 14:06:31 UTC (rev 11914)
+++ code/branches/3DPacman_FS18/data/levels/3DPacman.oxw	2018-04-26 14:11:19 UTC (rev 11915)
@@ -15,7 +15,10 @@
   include("templates/PacmanGelb.oxt")
 ?>
 
-<Level>
+<Level
+  plugins = pacman
+  gametype = Pacman
+>
 
   <templates>
     <Template link=lodtemplate_default />
@@ -30,36 +33,49 @@
     <Light type=directional position="0,0,0" direction="0.253, 0.593, -0.765" diffuse="1.0, 0.9, 0.9, 1.0" specular="1.0, 0.9, 0.9, 1.0"/>
     <SpawnPoint team=0 position="0,10,245" lookat="0,0,0" spawnclass=PacmanGelb pawndesign=PacmanGelb />
 
-<PacmanGhost position="215,10,245" resetposition="215,10,220">
+
+<PacmanGhost position="135,10,15" resetposition="135,10,15">
     <attached>
         <Model position="0,0,0" mesh="PacmanGhostRed.mesh" scale="5" />
     </attached>
 </PacmanGhost>
 
-<PacmanGhost position="215,10,245" resetposition="215,10,220">
+<PacmanGhost position="135,10,15" resetposition="135,10,15">
     <attached>
         <Model position="0,0,0" mesh="PacmanGhostBlue.mesh" scale="5" />
     </attached>
 </PacmanGhost>
 
-<PacmanGhost position="215,10,245" resetposition="215,10,220">
+<PacmanGhost position="135,10,15" resetposition="135,10,15">
     <attached>
         <Model position="0,0,0" mesh="PacmanGhostOrange.mesh" scale="5" />
     </attached>
 </PacmanGhost>
 
-<PacmanGhost position="215,10,245" resetposition="215,10,220">
+<PacmanGhost position="135,10,15" resetposition="135,10,15">
     <attached>
         <Model position="0,0,0" mesh="PacmanGhostPink.mesh" scale="5" />
     </attached>
 </PacmanGhost>
 
-<PacmanPointSphere position="0,10,0" resetposition="0,10,0">
+<PacmanPointSphere position="0,10,0">
     <attached>
         <Model position="0,0,0" mesh="PacmanPointSphere.mesh" scale="5" />
     </attached>
 </PacmanPointSphere>
 
+<PacmanPointSphere position="215,10,245">
+    <attached>
+        <Model position="0,0,0" mesh="PacmanPointSphere.mesh" scale="5" />
+    </attached>
+</PacmanPointSphere>
+
+<PacmanPointSphere position="215,10,195">
+    <attached>
+        <Model position="0,0,0" mesh="PacmanPointSphere.mesh" scale="5" />
+    </attached>
+</PacmanPointSphere>
+
 <StaticEntity position="0,0,25" direction="0,0,0" collisionType=static mass=100000 friction=0.01 >
     <attached> 
         <Model position="0,0,0" mesh="PacmanMap.mesh" scale="50" /> 

Modified: code/branches/3DPacman_FS18/src/modules/pacman/CMakeLists.txt
===================================================================
--- code/branches/3DPacman_FS18/src/modules/pacman/CMakeLists.txt	2018-04-26 14:06:31 UTC (rev 11914)
+++ code/branches/3DPacman_FS18/src/modules/pacman/CMakeLists.txt	2018-04-26 14:11:19 UTC (rev 11915)
@@ -1,5 +1,4 @@
-SET_SOURCE_FILES(PICKUP_SRC_FILES
-  
+SET_SOURCE_FILES(Pacman_SRC_FILES
   Pacman.cc
   PacmanGhost.cc
   PacmanGelb.cc
@@ -6,8 +5,8 @@
   PacmanPointSphere.cc
 )
 
-ORXONOX_ADD_LIBRARY(Pacman
-  MODULE
+ORXONOX_ADD_LIBRARY(pacman
+  PLUGIN
   FIND_HEADER_FILES
   TOLUA_FILES
 
@@ -16,6 +15,5 @@
   LINK_LIBRARIES
     orxonox
     objects
-    pickup
-  SOURCE_FILES ${PICKUP_SRC_FILES}
+  SOURCE_FILES ${Pacman_SRC_FILES}
 )

Modified: code/branches/3DPacman_FS18/src/modules/pacman/Pacman.cc
===================================================================
--- code/branches/3DPacman_FS18/src/modules/pacman/Pacman.cc	2018-04-26 14:06:31 UTC (rev 11914)
+++ code/branches/3DPacman_FS18/src/modules/pacman/Pacman.cc	2018-04-26 14:11:19 UTC (rev 11915)
@@ -37,13 +37,13 @@
 
 namespace orxonox
 {
-    RegisterUnloadableClass(Pacman);
+    RegisterClass(Pacman);
 
     Pacman::Pacman(Context* context) : Deathmatch(context)
     {
         RegisterObject(Pacman);
 
-        lives = 3;
+        lives = 10;
         point = 0;
         level = 1;
 
@@ -56,11 +56,12 @@
 
 
     PacmanGhost* ghosts[4];
-    PacmanPointSphere* spheres[1];
 
 
     void Pacman::tick(float dt)
     {
+        SUPER(Pacman, tick, dt);
+
         int i = 0;
         for(PacmanGhost* nextghost : ObjectList<PacmanGhost>()){
             ghosts[i] = nextghost;
@@ -73,12 +74,15 @@
             currentPosition = player->getWorldPosition();
         }
 
+
         bcolli = false;
         for(int nrghost = 0; (nrghost<3) && (!bcolli); ++nrghost){
             bcolli = collis(ghosts[nrghost]->getPosition(), currentPosition);
+            //orxout() << "GHOST" << nrghost << ghosts[nrghost]->getPosition() << endl;
         }
+
         if(bcolli){
-            this->catched();
+          this->catched();
         }
 
         i = 0;
@@ -88,13 +92,11 @@
             }
         }
 
-        SUPER(Pacman, tick, dt);
-
     }
 
 
     bool Pacman::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))
+        if((abs(one.x-other.x)<7) && (abs(one.y-other.y)<7) && (abs(one.z-other.z)<7))
             return true;
         return false;
     }
@@ -106,10 +108,8 @@
     } 
 
     void Pacman::posreset(){
-        int i = 0;
         for(PacmanGhost* nextghost : ObjectList<PacmanGhost>()){
             nextghost->resetGhost();
-            i++;
         }
         player->setPosition(startposplayer);
     }
@@ -117,7 +117,6 @@
     void Pacman::takePoint(PacmanPointSphere* taken){
         ++point;
         if(point == totallevelpoint) this->levelUp();
-
         Vector3 postaken = taken->getPosition();
         postaken.y = -50;
         taken->setPosition(postaken);
@@ -140,22 +139,10 @@
 
     void Pacman::start()
     {
-        orxout() << "start" << endl;
-        
         Deathmatch::start();
     }
 
-    void Pacman::playerPreSpawn(PlayerInfo* player)
-    {
-        //PlayerInfo* playerInfo_;
-        //this->playerInfo_ = player;
-        if(lives <= 0)
-        {
-            this->end();
-        }
-    }
 
-
     void Pacman::end()
     {
         if (Highscore::exists())

Modified: code/branches/3DPacman_FS18/src/modules/pacman/Pacman.h
===================================================================
--- code/branches/3DPacman_FS18/src/modules/pacman/Pacman.h	2018-04-26 14:06:31 UTC (rev 11914)
+++ code/branches/3DPacman_FS18/src/modules/pacman/Pacman.h	2018-04-26 14:11:19 UTC (rev 11915)
@@ -71,8 +71,6 @@
 
             virtual void tick(float dt) override;
 
-            virtual void playerPreSpawn(PlayerInfo* player) override;
-
             void levelUp();
             bool collis(Vector3 one, Vector3 other);
             void catched();
@@ -94,7 +92,7 @@
             PacmanGelb* player;
             bool bcolli = false;
             Vector3 startposplayer = Vector3(0,10,245);
-            int totallevelpoint = 1;
+            int totallevelpoint = 3;
             
        private:
 

Modified: code/branches/3DPacman_FS18/src/modules/pacman/PacmanGhost.cc
===================================================================
--- code/branches/3DPacman_FS18/src/modules/pacman/PacmanGhost.cc	2018-04-26 14:06:31 UTC (rev 11914)
+++ code/branches/3DPacman_FS18/src/modules/pacman/PacmanGhost.cc	2018-04-26 14:11:19 UTC (rev 11915)
@@ -49,7 +49,7 @@
 
         this->setCollisionType(CollisionType::Dynamic);
 
-        this->resetposition = Vector3(0,20,245); //Set Default start position
+        this->resetposition = this->getPosition(); //Set Default start position
         
         this->actuelposition = this->getPosition();
         
@@ -80,8 +80,14 @@
 
 
     
-    Vector3 possibleposition[] = {Vector3(175,10,245),Vector3(215,10,245),Vector3(215,10,195),Vector3(185,10,195),Vector3(135,10,195),
-        Vector3(185,10,150),Vector3(135,10,145),Vector3(215,10,150)};
+    Vector3 possibleposition[] = {Vector3(20,10,245),Vector3(215,10,245),Vector3(215,10,195),Vector3(185,10,195),Vector3(135,10,195), //0-4
+        Vector3(185,10,150),Vector3(135,10,150),Vector3(215,10,150),Vector3(215,10,105),Vector3(135,10,105), //5-9
+        Vector3(135,10,15),Vector3(135,10,-85),Vector3(215,10,-85),Vector3(135,10,-135),Vector3(215,10,-135), //10-14
+        Vector3(215,10,-195),Vector3(135,10,-195),Vector3(20,10,195),Vector3(-20,10,195),Vector3(-20,10,245), //15-19
+        Vector3(-215,10,245),Vector3(-215,10,195),Vector3(-185,10,195),Vector3(-135,10,195),Vector3(-70,10,195), //20-24
+        Vector3(70,10,195),Vector3(70,10,150),Vector3(20,10,150),Vector3(-20,10,150),Vector3(-70,10,150), //25-29
+        Vector3(-135,10,150),Vector3(-185,10,150),Vector3(-215,10,150),Vector3(-215,10,105),Vector3(-135,10,105) //30-34
+    };
 
     /**
     @brief
@@ -98,18 +104,18 @@
         this->actuelposition = this->getPosition();
         
         //Stop, if target arrived
-        if((abs(this->actuelposition.x - this->target_x)<0.1) && (abs(this->actuelposition.z - this->target_z)<0.1)){
+        if((abs(this->actuelposition.x - this->target_x)<0.5) && (abs(this->actuelposition.z - this->target_z)<0.5)){
                  this->ismoving = false;
         }
 
         //Move, if ghost hasn't arrived yet
         if(this->ismoving){
-            if(!(abs(this->actuelposition.z-target_z)<0.1)) {
-                velocity = Vector3(0,0,-sgn(this->actuelposition.z-this->target_z));
+            if(!(abs(this->actuelposition.z-target_z)<0.5)) {
+                velocity = Vector3(0,0,-sgn(this->actuelposition.z-this->target_z)*2);
                 move(dt, actuelposition, velocity);
             }    
-            if(!(abs(this->actuelposition.x-target_x)<0.1)){
-                velocity = Vector3(-sgn(this->actuelposition.x-this->target_x),0,0);
+            if(!(abs(this->actuelposition.x-target_x)<0.5)){
+                velocity = Vector3(-sgn(this->actuelposition.x-this->target_x)*2,0,0);
                 move(dt, actuelposition, velocity);
             }
         }
@@ -117,7 +123,7 @@
         //Check on which position ghost has arrived and set new target
          else{
             if(findpos(actuelposition,possibleposition[0])){
-            	setnewTarget(1);
+            	setnewTarget(1,17,19);
             }
             else if(findpos(actuelposition,possibleposition[1])){
             	setnewTarget(0,2);
@@ -135,11 +141,92 @@
             	setnewTarget(3,7);
             }
             else if(findpos(actuelposition,possibleposition[6])){
-                setnewTarget(4);
+                setnewTarget(4,9,26);
             }
             else if(findpos(actuelposition,possibleposition[7])){
-                setnewTarget(5);
+                setnewTarget(5,8);
             }
+            else if(findpos(actuelposition,possibleposition[8])){
+                setnewTarget(7,9);
+            }
+            else if(findpos(actuelposition,possibleposition[9])){
+                setnewTarget(6,8,10); //38
+            }
+            else if(findpos(actuelposition,possibleposition[10])){
+                setnewTarget(9,11); //45,9
+            }
+            else if(findpos(actuelposition,possibleposition[11])){
+                setnewTarget(10,12,13);
+            }
+            else if(findpos(actuelposition,possibleposition[12])){
+                setnewTarget(11,14);
+            }
+            else if(findpos(actuelposition,possibleposition[13])){
+                setnewTarget(11,14,16); //61
+            }
+            else if(findpos(actuelposition,possibleposition[14])){
+                setnewTarget(12,13,15);
+            }
+            else if(findpos(actuelposition,possibleposition[15])){
+                setnewTarget(14,16);
+            }
+            else if(findpos(actuelposition,possibleposition[16])){
+                setnewTarget(13,15); //62
+            }
+            else if(findpos(actuelposition,possibleposition[17])){
+                setnewTarget(0,25);
+            }
+            else if(findpos(actuelposition,possibleposition[18])){
+                setnewTarget(19,24);
+            }
+            else if(findpos(actuelposition,possibleposition[19])){
+                setnewTarget(0,18,20);
+            }
+            else if(findpos(actuelposition,possibleposition[20])){
+                setnewTarget(19,21);
+            }
+            else if(findpos(actuelposition,possibleposition[21])){
+                setnewTarget(20,22);
+            }
+            else if(findpos(actuelposition,possibleposition[22])){
+                setnewTarget(21,23,31);
+            }
+            else if(findpos(actuelposition,possibleposition[23])){
+                setnewTarget(22,30);
+            }
+            else if(findpos(actuelposition,possibleposition[24])){
+                setnewTarget(18,29);
+            }
+            else if(findpos(actuelposition,possibleposition[25])){
+                setnewTarget(17,26);
+            }
+            else if(findpos(actuelposition,possibleposition[26])){
+                setnewTarget(6,25,27);
+            }
+            else if(findpos(actuelposition,possibleposition[27])){
+                setnewTarget(26,28);//37
+            }
+            else if(findpos(actuelposition,possibleposition[28])){
+                setnewTarget(27,29); //36
+            }
+            else if(findpos(actuelposition,possibleposition[29])){
+                setnewTarget(24,28,30);
+            }
+            else if(findpos(actuelposition,possibleposition[30])){
+                setnewTarget(23,29,34);
+            }
+            else if(findpos(actuelposition,possibleposition[31])){
+                setnewTarget(22,32);
+            }
+            else if(findpos(actuelposition,possibleposition[32])){
+                setnewTarget(31,33);
+            }
+            else if(findpos(actuelposition,possibleposition[33])){
+                setnewTarget(32,34);
+            }
+            else if(findpos(actuelposition,possibleposition[34])){
+                setnewTarget(30,33);//35,42
+            }
 
 
             else{
@@ -229,138 +316,16 @@
     }
 
     bool PacmanGhost::findpos(Vector3 one, Vector3 other){
-        if((abs(one.x - other.x)<0.1) && (abs(one.z - other.z)<0.1)) return true;
+        if((abs(one.x - other.x)<0.5) && (abs(one.z - other.z)<0.5)) return true;
         return false;
     }
 
     void PacmanGhost::resetGhost(){
-        this->setPosition(resetposition);
+        this->setPosition(this->resetposition);
+        this->ismoving = false;
+        this->actuelposition = this->getPosition();
+        
+        this->target_x = actuelposition.x;
+        this->target_z = actuelposition.z;
     }
-}
-
-/*
-//Check on which position ghost has arrived and set new target
-         else{
-            if(findpos(actuelposition,possibleposition[0])){
-                decision = rand()%1;
-            switch(decision){
-                case 0:
-                    this->target_x = possibleposition[1].x;
-                    this->target_z = possibleposition[1].z; 
-                    this->ismoving = true;
-                    break;
-            }
-            
-            }
-            else if(findpos(actuelposition,possibleposition[1])){
-                decision = rand()%2;
-            switch(decision){
-                case 0:
-                    this->target_x = possibleposition[0].x;
-                    this->target_z = possibleposition[0].z; 
-                    this->ismoving = true;
-                    break;
-                case 1:
-                    this->target_x = possibleposition[2].x;
-                    this->target_z = possibleposition[2].z; 
-                    this->ismoving = true;
-                    break;    
-            }
-
-            }
-            else if(findpos(actuelposition,possibleposition[2])){
-                decision = rand()%2;
-            switch(decision){
-                case 0:
-                    this->target_x = possibleposition[1].x;
-                    this->target_z = possibleposition[1].z; 
-                    this->ismoving = true;
-                    break;
-                case 1:
-                    this->target_x = possibleposition[3].x;
-                    this->target_z = possibleposition[3].z; 
-                    this->ismoving = true;
-                    break;
-            }
-            
-            }
-
-            else if(findpos(actuelposition,possibleposition[3])){
-                decision = rand()%3;
-            switch(decision){
-                case 0:
-                    this->target_x = possibleposition[2].x;
-                    this->target_z = possibleposition[2].z; 
-                    this->ismoving = true;
-                    break;
-                case 1:
-                    this->target_x = possibleposition[4].x;
-                    this->target_z = possibleposition[4].z; 
-                    this->ismoving = true;
-                    break;
-                case 2:
-                    this->target_x = possibleposition[5].x;
-                    this->target_z = possibleposition[5].z; 
-                    this->ismoving = true;
-                    break;        
-            }
-            }
-
-            else if(findpos(actuelposition,possibleposition[4])){
-                decision = rand()%2;
-            switch(decision){
-                case 0:
-                    this->target_x = possibleposition[3].x;
-                    this->target_z = possibleposition[3].z; 
-                    this->ismoving = true;
-                    break;
-                case 1:
-                    this->target_x = possibleposition[6].x;
-                    this->target_z = possibleposition[6].z; 
-                    this->ismoving = true;
-                    break;
-            }
-            }
-
-            else if(findpos(actuelposition,possibleposition[5])){
-                decision = rand()%2;
-            switch(decision){
-                case 0:
-                    this->target_x = possibleposition[3].x;
-                    this->target_z = possibleposition[3].z; 
-                    this->ismoving = true;
-                    break;
-                case 1:
-                    this->target_x = possibleposition[7].x;
-                    this->target_z = possibleposition[7].z; 
-                    this->ismoving = true;
-                    break;
-            }
-            }
-
-            else if(findpos(actuelposition,possibleposition[6])){
-                decision = rand()%1;
-            switch(decision){
-                case 0:
-                    this->target_x = possibleposition[4].x;
-                    this->target_z = possibleposition[4].z; 
-                    this->ismoving = true;
-                    break;
-            }
-            }
-
-            else if(findpos(actuelposition,possibleposition[7])){
-                decision = rand()%1;
-            switch(decision){
-                case 0:
-                    this->target_x = possibleposition[5].x;
-                    this->target_z = possibleposition[5].z; 
-                    this->ismoving = true;
-                    break;
-            }
-            }
-
-
-            else{
-            } //End of Position table
-            */
\ No newline at end of file
+}
\ No newline at end of file

Modified: code/branches/3DPacman_FS18/src/modules/pacman/PacmanPointSphere.cc
===================================================================
--- code/branches/3DPacman_FS18/src/modules/pacman/PacmanPointSphere.cc	2018-04-26 14:06:31 UTC (rev 11914)
+++ code/branches/3DPacman_FS18/src/modules/pacman/PacmanPointSphere.cc	2018-04-26 14:11:19 UTC (rev 11915)
@@ -63,8 +63,6 @@
     void PacmanPointSphere::XMLPort(Element& xmlelement, XMLPort::Mode mode)
     {
         SUPER(PacmanPointSphere, XMLPort, xmlelement, mode);
-
-        XMLPortParam(PacmanPointSphere, "resetposition", setResetPosition, getResetPosition, xmlelement, mode);
     }
 
 

Modified: code/branches/3DPacman_FS18/src/modules/pacman/PacmanPointSphere.h
===================================================================
--- code/branches/3DPacman_FS18/src/modules/pacman/PacmanPointSphere.h	2018-04-26 14:06:31 UTC (rev 11914)
+++ code/branches/3DPacman_FS18/src/modules/pacman/PacmanPointSphere.h	2018-04-26 14:11:19 UTC (rev 11915)
@@ -48,13 +48,6 @@
 
             bool taken(Vector3 playerpos);
             void resetPacmanPointSphere();
-
-            inline void setResetPosition(Vector3 rpos)
-                { this->resetposition = rpos; }    
-            
-            inline Vector3 getResetPosition()
-               { return this->resetposition; }        
-
         private:
             
             Vector3 resetposition;



More information about the Orxonox-commit mailing list