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

dreherm at orxonox.net dreherm at orxonox.net
Sat May 5 00:12:36 CEST 2018


Author: dreherm
Date: 2018-05-05 00:12:36 +0200 (Sat, 05 May 2018)
New Revision: 11945

Modified:
   code/branches/3DPacman_FS18/data/levels/3DPacman.oxw
   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/PacmanGhost.h
Log:
Afraid Test 7

Modified: code/branches/3DPacman_FS18/data/levels/3DPacman.oxw
===================================================================
--- code/branches/3DPacman_FS18/data/levels/3DPacman.oxw	2018-05-04 21:42:09 UTC (rev 11944)
+++ code/branches/3DPacman_FS18/data/levels/3DPacman.oxw	2018-05-04 22:12:36 UTC (rev 11945)
@@ -59,9 +59,18 @@
 </PacmanGhost>
 
 
+<PacmanGhost position="0,-20,0" >
+    <attached>
+        <Model position="0,0,0" mesh="PacmanGhostAfraid.mesh" scale="5" />
+    </attached>
+</PacmanGhost>
 
+<PacmanGhost position="0,-20,0" >
+    <attached>
+        <Model position="0,0,0" mesh="PacmanGhostAfraid.mesh" scale="5" />
+    </attached>
+</PacmanGhost>
 
-
 <PacmanGhost position="0,-20,0" >
     <attached>
         <Model position="0,0,0" mesh="PacmanGhostAfraid.mesh" scale="5" />
@@ -68,15 +77,14 @@
     </attached>
 </PacmanGhost>
 
-<PacmanPointAfraid position="215,10,195">
+<PacmanGhost position="0,-20,0" >
     <attached>
-        <Model position="0,0,0" mesh="PacmanPointAfraid.mesh" scale="5" />
+        <Model position="0,0,0" mesh="PacmanGhostAfraid.mesh" scale="5" />
     </attached>
-</PacmanPointAfraid>
+</PacmanGhost>
 
 
 
-
 <!-- POINTS -->
 <PacmanPointSphere position="0,10,0">
     <attached>

Modified: code/branches/3DPacman_FS18/src/modules/pacman/Pacman.cc
===================================================================
--- code/branches/3DPacman_FS18/src/modules/pacman/Pacman.cc	2018-05-04 21:42:09 UTC (rev 11944)
+++ code/branches/3DPacman_FS18/src/modules/pacman/Pacman.cc	2018-05-04 22:12:36 UTC (rev 11945)
@@ -69,7 +69,7 @@
             timer = timer - dt;
             if(timer<=0){
                 afraid = false;
-                timer = 0;
+                this->setNormal();
             }
         }
 
@@ -87,7 +87,7 @@
 
 
         bcolli = false;
-        for(int nrghost = 0; (nrghost<3) && (!bcolli); ++nrghost){
+        for(int nrghost = 0; (nrghost<8) && (!bcolli); ++nrghost){
             bcolli = collis(ghosts[nrghost]->getPosition(), currentPosition);
             //orxout() << "GHOST" << nrghost << ghosts[nrghost]->getPosition() << endl;
         }
@@ -126,7 +126,7 @@
         this->posreset();
         }
     else{
-        for(int nrghost = 0; nrghost<3; ++nrghost){
+        for(int nrghost = 0; nrghost<8; ++nrghost){
         bcolli = collis(ghosts[nrghost]->getPosition(), currentPosition);
         if(bcolli) ghosts[nrghost]->resetGhost();
         bcolli = false;
@@ -135,10 +135,35 @@
     }
 
     void Pacman::setAfraid(){
-        afraid = true;
+
         timer = 10; //Set timer to 10 seconds
+
+        //Change normal Ghosts with afraid ones
+        if(!afraid){
+            ghosts[0]->changewith(ghosts[4]);
+            ghosts[1]->changewith(ghosts[5]);
+            ghosts[2]->changewith(ghosts[6]);
+            ghosts[3]->changewith(ghosts[7]);
+        }
+
+        afraid = true; 
     } 
 
+    void Pacman::setNormal(){
+
+        timer = 0;
+
+        //Change normal Ghosts with afraid ones
+        if(afraid){
+            ghosts[4]->changewith(ghosts[0]);
+            ghosts[5]->changewith(ghosts[1]);
+            ghosts[6]->changewith(ghosts[2]);
+            ghosts[7]->changewith(ghosts[3]);
+        }
+
+        afraid = false; 
+    } 
+
     void Pacman::posreset(){
         for(PacmanGhost* nextghost : ObjectList<PacmanGhost>()){
             nextghost->resetGhost();

Modified: code/branches/3DPacman_FS18/src/modules/pacman/Pacman.h
===================================================================
--- code/branches/3DPacman_FS18/src/modules/pacman/Pacman.h	2018-05-04 21:42:09 UTC (rev 11944)
+++ code/branches/3DPacman_FS18/src/modules/pacman/Pacman.h	2018-05-04 22:12:36 UTC (rev 11945)
@@ -80,6 +80,7 @@
             PacmanGelb* getPlayer();
             int getPoints();
             void setAfraid();
+            void setNormal();
 
 
             bool bEndGame;

Modified: code/branches/3DPacman_FS18/src/modules/pacman/PacmanGhost.cc
===================================================================
--- code/branches/3DPacman_FS18/src/modules/pacman/PacmanGhost.cc	2018-05-04 21:42:09 UTC (rev 11944)
+++ code/branches/3DPacman_FS18/src/modules/pacman/PacmanGhost.cc	2018-05-04 22:12:36 UTC (rev 11945)
@@ -50,6 +50,9 @@
         this->setCollisionType(CollisionType::Dynamic);
         
         this->actuelposition = this->getPosition();
+
+        if(findpos(actuelposition, Vector3(0,-20,0)))
+            dontmove = true;
         
         this->target_x = actuelposition.x;
         this->target_z = actuelposition.z; 
@@ -413,8 +416,18 @@
             
 	}
 
+    void changewith(PacmanGhost* otherghost){
+        otherghost->setPosition(this->getPosition());
+        this->setPosition(0,-20,0);
+        otherghost->target_x = this->target_x;   //Probleme bei parallelen Porzessen
+        otherghost->target_y = this->target_y;
+        otherghost->ismoving = this->ismoving;
 
+        this->dontmove = true;
+        otherghost->dontmove = false;
+    }
 
+
     void PacmanGhost::move(float dt, Vector3 actuelposition, Vector3 velocity){
         if(!dontmove)
             this->setPosition(Vector3(actuelposition.x+20*velocity.x*dt,10,actuelposition.z+20*velocity.z*dt));
@@ -421,7 +434,7 @@
     }
 
     bool PacmanGhost::findpos(Vector3 one, Vector3 other){
-       if((abs(one.x - other.x)<0.5) && (abs(one.z - other.z)<0.5)) return true;
+       if((abs(one.x - other.x)<0.5) && (abs(one.y - other.y)<0.5) && (abs(one.z - other.z)<0.5)) return true;
         return false;
     }
 

Modified: code/branches/3DPacman_FS18/src/modules/pacman/PacmanGhost.h
===================================================================
--- code/branches/3DPacman_FS18/src/modules/pacman/PacmanGhost.h	2018-05-04 21:42:09 UTC (rev 11944)
+++ code/branches/3DPacman_FS18/src/modules/pacman/PacmanGhost.h	2018-05-04 22:12:36 UTC (rev 11945)
@@ -54,17 +54,19 @@
             void setnewTarget(int firstdec, int seconddec);
             void setnewTarget(int firstdec, int seconddec, int thirddec);
             void setnewTarget(int firstdec, int seconddec, int thirddec, int fourthdec);
+            void changewith(PacmanGhost* otherghost);
 
-
             bool findpos(Vector3 one, Vector3 other);      
             void changemovability();
             bool dontmove = false;
-        private:
+
+            Vector3 actuelposition;
             bool ismoving = false;
-            int decision = 0; //Gives the random which way information to the ghost.
             int target_x = 0; 
             int target_z = 0; 
-            Vector3 actuelposition;
+            
+        private:
+            int decision = 0; //Gives the random which way information to the ghost.
             Vector3 velocity;
             Vector3 resetposition = Vector3(0,10,15);
     };



More information about the Orxonox-commit mailing list