[Orxonox-commit 7322] r11939 - code/branches/3DPacman_FS18/src/modules/pacman

dreherm at orxonox.net dreherm at orxonox.net
Fri May 4 23:22:51 CEST 2018


Author: dreherm
Date: 2018-05-04 23:22:50 +0200 (Fri, 04 May 2018)
New Revision: 11939

Modified:
   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/PacmanPointAfraid.cc
   code/branches/3DPacman_FS18/src/modules/pacman/PacmanPointAfraid.h
Log:
Afraid Test 1

Modified: code/branches/3DPacman_FS18/src/modules/pacman/CMakeLists.txt
===================================================================
--- code/branches/3DPacman_FS18/src/modules/pacman/CMakeLists.txt	2018-05-03 14:09:37 UTC (rev 11938)
+++ code/branches/3DPacman_FS18/src/modules/pacman/CMakeLists.txt	2018-05-04 21:22:50 UTC (rev 11939)
@@ -3,6 +3,7 @@
   PacmanGhost.cc
   PacmanGelb.cc
   PacmanPointSphere.cc
+  PacmanPointAfraid.cc
 )
 
 ORXONOX_ADD_LIBRARY(pacman

Modified: code/branches/3DPacman_FS18/src/modules/pacman/Pacman.cc
===================================================================
--- code/branches/3DPacman_FS18/src/modules/pacman/Pacman.cc	2018-05-03 14:09:37 UTC (rev 11938)
+++ code/branches/3DPacman_FS18/src/modules/pacman/Pacman.cc	2018-05-04 21:22:50 UTC (rev 11939)
@@ -65,6 +65,14 @@
     {
         SUPER(Pacman, tick, dt);
 
+        if(!timer){
+            timer = timer - dt;
+            if(timer<=0){
+                afraid = false;
+                timer = 0;
+            }
+        }
+
         int i = 0;
         for(PacmanGhost* nextghost : ObjectList<PacmanGhost>()){
             ghosts[i] = nextghost;
@@ -118,7 +126,6 @@
         this->posreset();
         }
     else{
-
         for(int nrghost = 0; nrghost<3; ++nrghost){
         bcolli = collis(ghosts[nrghost]->getPosition(), currentPosition);
         if(bcolli) ghosts[nrghost]->resetGhost();
@@ -129,6 +136,7 @@
 
     void setAfraid(){
         afraid = true;
+        timer = 10; //Set timer to 10 seconds
     } 
 
     void Pacman::posreset(){

Modified: code/branches/3DPacman_FS18/src/modules/pacman/PacmanPointAfraid.cc
===================================================================
--- code/branches/3DPacman_FS18/src/modules/pacman/PacmanPointAfraid.cc	2018-05-03 14:09:37 UTC (rev 11938)
+++ code/branches/3DPacman_FS18/src/modules/pacman/PacmanPointAfraid.cc	2018-05-04 21:22:50 UTC (rev 11939)
@@ -26,7 +26,7 @@
  *
  */
 
-#include "PacmanPointSphere.h"
+#include "PacmanPointAfraid.h"
 
 #include "core/CoreIncludes.h"
 #include "BulletDynamics/Dynamics/btRigidBody.h"
@@ -33,7 +33,7 @@
 
 namespace orxonox
 {
-    RegisterClass(PacmanPointSphere);
+    RegisterClass(PacmanPointAfraid);
 
     /**
     @brief
@@ -41,9 +41,9 @@
     @param creator
         The creator of this object.
     */
-    PacmanPointSphere::PacmanPointSphere(Context* context) : ControllableEntity(context)
+    PacmanPointAfraid::PacmanPointAfraid(Context* context) : ControllableEntity(context)
     {
-        RegisterObject(PacmanPointSphere);
+        RegisterObject(PacmanPointAfraid);
         this->setCollisionType(CollisionType::None); 
     }
 
@@ -51,7 +51,7 @@
     @brief
         Destructor. Destroys controller, if present.
     */
-    PacmanPointSphere::~PacmanPointSphere()
+    PacmanPointAfraid::~PacmanPointAfraid()
     {
         // Deletes the controller if the object was initialized and the pointer to the controller is not NULL.
     }
@@ -60,18 +60,18 @@
     @brief
         Method for creating a AutonomousDrone through XML.
     */
-    void PacmanPointSphere::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+    void PacmanPointAfraid::XMLPort(Element& xmlelement, XMLPort::Mode mode)
     {
-        SUPER(PacmanPointSphere, XMLPort, xmlelement, mode);
+        SUPER(PacmanPointAfraid, XMLPort, xmlelement, mode);
     }
 
 
-    void PacmanPointSphere::tick(float dt)
+    void PacmanPointAfraid::tick(float dt)
     {
-        SUPER(PacmanPointSphere, tick, dt);
+        SUPER(PacmanPointAfraid, tick, dt);
     }
 
-    bool PacmanPointSphere::taken(Vector3 playerpos)
+    bool PacmanPointAfraid::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));
@@ -82,7 +82,7 @@
     }
 
 
-    void PacmanPointSphere::resetPacmanPointSphere(){
+    void PacmanPointAfraid::resetPacmanPointAfraid(){
         this->setPosition(resetposition);
     }
 }

Modified: code/branches/3DPacman_FS18/src/modules/pacman/PacmanPointAfraid.h
===================================================================
--- code/branches/3DPacman_FS18/src/modules/pacman/PacmanPointAfraid.h	2018-05-03 14:09:37 UTC (rev 11938)
+++ code/branches/3DPacman_FS18/src/modules/pacman/PacmanPointAfraid.h	2018-05-04 21:22:50 UTC (rev 11939)
@@ -26,8 +26,8 @@
  *
  */
 
-#ifndef _PacmanPointSphere_H__
-#define _PacmanPointSphere_H__
+#ifndef _PacmanPointAfraid_H__
+#define _PacmanPointAfraid_H__
 
 #include "OrxonoxPrereqs.h"
 
@@ -37,17 +37,17 @@
 
 namespace orxonox {
 
-    class _OrxonoxExport PacmanPointSphere : public ControllableEntity
+    class _OrxonoxExport PacmanPointAfraid : public ControllableEntity
     {
         public:
-            PacmanPointSphere(Context* context);
-            virtual ~PacmanPointSphere();
+            PacmanPointAfraid(Context* context);
+            virtual ~PacmanPointAfraid();
 
             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();
+            void resetPacmanPointAfraid();
         private:
             
             Vector3 resetposition;



More information about the Orxonox-commit mailing list