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

dreherm at orxonox.net dreherm at orxonox.net
Thu May 3 15:45:20 CEST 2018


Author: dreherm
Date: 2018-05-03 15:45:20 +0200 (Thu, 03 May 2018)
New Revision: 11933

Added:
   code/branches/3DPacman_FS18/src/modules/pacman/PacmanPointAfraid.cc
   code/branches/3DPacman_FS18/src/modules/pacman/PacmanPointAfraid.h
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 Ghosts

Modified: code/branches/3DPacman_FS18/data/levels/3DPacman.oxw
===================================================================
--- code/branches/3DPacman_FS18/data/levels/3DPacman.oxw	2018-05-03 13:16:09 UTC (rev 11932)
+++ code/branches/3DPacman_FS18/data/levels/3DPacman.oxw	2018-05-03 13:45:20 UTC (rev 11933)
@@ -58,6 +58,25 @@
     </attached>
 </PacmanGhost>
 
+
+
+
+
+<PacmanGhost position="0,-20,0" >
+    <attached>
+        <Model position="0,0,0" mesh="PacmanGhostAfraid.mesh" scale="5" />
+    </attached>
+</PacmanGhost>
+
+<PacmanPointAfraid position="215,10,195">
+    <attached>
+        <Model position="0,0,0" mesh="PacmanPointAfraid.mesh" scale="5" />
+    </attached>
+</PacmanPointAfraid>
+
+
+
+
 <!-- POINTS -->
 <PacmanPointSphere position="0,10,0">
     <attached>
@@ -77,6 +96,11 @@
     </attached>
 </PacmanPointSphere>
 
+<PacmanPointAfraid position="215,10,195">
+    <attached>
+        <Model position="0,0,0" mesh="PacmanPointAfraid.mesh" scale="5" />
+    </attached>
+</PacmanPointAfraid>
 
 <!-- Map -->
 <StaticEntity position="0,0,25" direction="0,0,0" collisionType=static mass=100000 friction=0.01 >

Modified: code/branches/3DPacman_FS18/src/modules/pacman/Pacman.cc
===================================================================
--- code/branches/3DPacman_FS18/src/modules/pacman/Pacman.cc	2018-05-03 13:16:09 UTC (rev 11932)
+++ code/branches/3DPacman_FS18/src/modules/pacman/Pacman.cc	2018-05-03 13:45:20 UTC (rev 11933)
@@ -95,6 +95,12 @@
             }
         }
 
+        for(PacmanPointAfraid* next : ObjectList<PacmanPointAfraid>()){
+            if(collis(next->getPosition(), currentPosition)){
+                setAfraid();
+            }
+        }
+
     }
 
 
@@ -105,9 +111,24 @@
     }
 
     void Pacman::catched(){
+
+    if(!afraid) {
         if(!lives) this->end();
         --lives;
         this->posreset();
+        }
+    else{
+
+        for(int nrghost = 0; nrghost<3; ++nrghost){
+        bcolli = collis(ghosts[nrghost]->getPosition(), currentPosition);
+        if(bcolli) ghosts[nrghost]->resetGhost();
+        bcolli = false;
+        }
+      }
+    }
+
+    void setAfraid(){
+        afraid = true;
     } 
 
     void Pacman::posreset(){

Modified: code/branches/3DPacman_FS18/src/modules/pacman/Pacman.h
===================================================================
--- code/branches/3DPacman_FS18/src/modules/pacman/Pacman.h	2018-05-03 13:16:09 UTC (rev 11932)
+++ code/branches/3DPacman_FS18/src/modules/pacman/Pacman.h	2018-05-03 13:45:20 UTC (rev 11933)
@@ -38,6 +38,7 @@
 #include "PacmanGelb.h"
 #include "PacmanGhost.h"
 #include "PacmanPointSphere.h"
+#include "PacmanPointAfraid.h"
 #include "Highscore.h"
 //#include "PlayerInfo.h"
 
@@ -94,6 +95,8 @@
             Vector3 startposplayer = Vector3(0,10,245);
             int totallevelpoint = 3;
             //bool firstGame;
+            bool afraid = false;
+            float timer = 0;
             
        private:
 

Modified: code/branches/3DPacman_FS18/src/modules/pacman/PacmanGhost.cc
===================================================================
--- code/branches/3DPacman_FS18/src/modules/pacman/PacmanGhost.cc	2018-05-03 13:16:09 UTC (rev 11932)
+++ code/branches/3DPacman_FS18/src/modules/pacman/PacmanGhost.cc	2018-05-03 13:45:20 UTC (rev 11933)
@@ -416,7 +416,8 @@
 
 
     void PacmanGhost::move(float dt, Vector3 actuelposition, Vector3 velocity){
-        this->setPosition(Vector3(actuelposition.x+20*velocity.x*dt,10,actuelposition.z+20*velocity.z*dt));
+        if(!dontmove)
+            this->setPosition(Vector3(actuelposition.x+20*velocity.x*dt,10,actuelposition.z+20*velocity.z*dt));
     }
 
     bool PacmanGhost::findpos(Vector3 one, Vector3 other){
@@ -424,6 +425,14 @@
         return false;
     }
 
+    void changemovability(){
+        if(dontmove){
+         dontmove = false;}
+        else{
+         dontmove = true;   
+        }
+    }
+
     void PacmanGhost::resetGhost(){
     
         this->setPosition(this->resetposition);

Modified: code/branches/3DPacman_FS18/src/modules/pacman/PacmanGhost.h
===================================================================
--- code/branches/3DPacman_FS18/src/modules/pacman/PacmanGhost.h	2018-05-03 13:16:09 UTC (rev 11932)
+++ code/branches/3DPacman_FS18/src/modules/pacman/PacmanGhost.h	2018-05-03 13:45:20 UTC (rev 11933)
@@ -57,9 +57,10 @@
 
 
             bool findpos(Vector3 one, Vector3 other);      
+            void changemovability();
 
-
         private:
+            bool dontmove = false;
             bool ismoving = false;
             int decision = 0; //Gives the random which way information to the ghost.
             int target_x = 0; 

Added: code/branches/3DPacman_FS18/src/modules/pacman/PacmanPointAfraid.cc
===================================================================
--- code/branches/3DPacman_FS18/src/modules/pacman/PacmanPointAfraid.cc	                        (rev 0)
+++ code/branches/3DPacman_FS18/src/modules/pacman/PacmanPointAfraid.cc	2018-05-03 13:45:20 UTC (rev 11933)
@@ -0,0 +1,88 @@
+/*
+ *   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:
+ *      Oli Scheuss
+ *   Co-authors:
+ *      Damian 'Mozork' Frick
+ *
+ */
+
+#include "PacmanPointSphere.h"
+
+#include "core/CoreIncludes.h"
+#include "BulletDynamics/Dynamics/btRigidBody.h"
+
+namespace orxonox
+{
+    RegisterClass(PacmanPointSphere);
+
+    /**
+    @brief
+        Constructor. Registers the object and initializes some default values.
+    @param creator
+        The creator of this object.
+    */
+    PacmanPointSphere::PacmanPointSphere(Context* context) : ControllableEntity(context)
+    {
+        RegisterObject(PacmanPointSphere);
+        this->setCollisionType(CollisionType::None); 
+    }
+
+    /**
+    @brief
+        Destructor. Destroys controller, if present.
+    */
+    PacmanPointSphere::~PacmanPointSphere()
+    {
+        // Deletes the controller if the object was initialized and the pointer to the controller is not NULL.
+    }
+
+    /**
+    @brief
+        Method for creating a AutonomousDrone through XML.
+    */
+    void PacmanPointSphere::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+    {
+        SUPER(PacmanPointSphere, XMLPort, xmlelement, mode);
+    }
+
+
+    void PacmanPointSphere::tick(float dt)
+    {
+        SUPER(PacmanPointSphere, tick, dt);
+    }
+
+    bool PacmanPointSphere::taken(Vector3 playerpos)
+    {
+      if((abs(this->resetposition.x - playerpos.x)<0.1) && (abs(this->resetposition.z - playerpos.z)<0.1)){
+        this->setPosition(Vector3(resetposition.x, -50, resetposition.z));
+        return true;
+      } 
+
+      return false;
+    }
+
+
+    void PacmanPointSphere::resetPacmanPointSphere(){
+        this->setPosition(resetposition);
+    }
+}


Property changes on: code/branches/3DPacman_FS18/src/modules/pacman/PacmanPointAfraid.cc
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Added: code/branches/3DPacman_FS18/src/modules/pacman/PacmanPointAfraid.h
===================================================================
--- code/branches/3DPacman_FS18/src/modules/pacman/PacmanPointAfraid.h	                        (rev 0)
+++ code/branches/3DPacman_FS18/src/modules/pacman/PacmanPointAfraid.h	2018-05-03 13:45:20 UTC (rev 11933)
@@ -0,0 +1,58 @@
+/*
+ *   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:
+ *      Oli Scheuss
+ *   Co-authors:
+ *      Damian 'Mozork' Frick
+ *
+ */
+
+#ifndef _PacmanPointSphere_H__
+#define _PacmanPointSphere_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "core/XMLPort.h"
+
+#include "worldentities/ControllableEntity.h"
+
+namespace orxonox {
+
+    class _OrxonoxExport PacmanPointSphere : public ControllableEntity
+    {
+        public:
+            PacmanPointSphere(Context* context);
+            virtual ~PacmanPointSphere();
+
+            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating an AutonomousDrone through XML.
+            virtual void tick(float dt); //!< Defines which actions the AutonomousDrone has to take in each tick.
+
+            bool taken(Vector3 playerpos);
+            void resetPacmanPointSphere();
+        private:
+            
+            Vector3 resetposition;
+    };
+
+}
+
+#endif


Property changes on: code/branches/3DPacman_FS18/src/modules/pacman/PacmanPointAfraid.h
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property


More information about the Orxonox-commit mailing list