[Orxonox-commit 7231] r11845 - code/branches/3DPacman_FS18/src/modules/Pacman

dreherm at orxonox.net dreherm at orxonox.net
Sun Apr 1 00:12:18 CEST 2018


Author: dreherm
Date: 2018-04-01 00:12:17 +0200 (Sun, 01 Apr 2018)
New Revision: 11845

Modified:
   code/branches/3DPacman_FS18/src/modules/Pacman/PacmanGhost.cc
   code/branches/3DPacman_FS18/src/modules/Pacman/PacmanGhost.h
Log:
Commit and check ghost class

Modified: code/branches/3DPacman_FS18/src/modules/Pacman/PacmanGhost.cc
===================================================================
--- code/branches/3DPacman_FS18/src/modules/Pacman/PacmanGhost.cc	2018-03-29 16:23:28 UTC (rev 11844)
+++ code/branches/3DPacman_FS18/src/modules/Pacman/PacmanGhost.cc	2018-03-31 22:12:17 UTC (rev 11845)
@@ -48,7 +48,7 @@
         this->localLinearAcceleration_.setValue(1, 1, 1);
         this->localAngularAcceleration_.setValue(1, 1, 1);
 
-        this->velocity.setValue(1, 0, 0);
+        this->velocity(1, 0, 0);
 
         this->setCollisionType(CollisionType::Dynamic);
 
@@ -114,27 +114,25 @@
 
         this->actuelposition = this->getPosition();
         
-        move();
-
-
-        /*
-
-        //Calculate next move
-
-        this->actuelposition = this->getPosition();
-
+        //Stop, if target arrived
         if(((this->actuelposition.x - this->target_x)<0.1) && ((this->actuelposition.z - this->target_z)<0.1)){
                  this->ismoving = false;
         }
 
+        //Move, if ghost hasn't arrived yet
         if(this->ismoving){
-            if(!((this->actuelposition.z-target_z)<0.1))
-                moveFrontBack(sgn(this->actuelposition.z-this->target_z)*dt*100);
-            if(!((this->actuelposition.x-target_x)<0.1))
-              moveRightLeft(sgn(this->actuelposition.x-this->target_x)*dt*100); //Assume dt is quite small
+            if(!((this->actuelposition.z-target_z)<0.1)) {
+                velocity = Vector3(sgn(this->actuelposition.x-this->target_x),sgn(this->actuelposition.y-this->target_y),sgn(this->actuelposition.z-this->target_z));
+                move(dt);
+            }    
+            if(!((this->actuelposition.x-target_x)<0.1)){
+                velocity = Vector3(sgn(this->actuelposition.x-this->target_x),sgn(this->actuelposition.y-this->target_y),sgn(this->actuelposition.z-this->target_z));
+                move(dt);
+            }
         }
-        
-        else{ //Check on which position ghost is
+
+        //Check on which position ghost has arrived and set new target
+         else{
             if(((this->actuelposition.x - possibleposition[0].x)<0.1) && ((this->actuelposition.z - possibleposition[0].z)<0.1)){
                 this->target_x = possibleposition[1].x;
                 this->target_z = possibleposition[1].z; 
@@ -148,12 +146,16 @@
             else{
             } //End of Position table
             }
-             */
+
     }
 
 
 
+    void move(float dt){
+        this->setPosition(actuelposition+velocity*dt);
+    }
 
+
     /**
     @brief
         Moves the AutonomousDrone in the negative z-direction (Front/Back) by an amount specified by the first component of the input 2-dim vector.
@@ -162,7 +164,7 @@
     */
     void PacmanGhost::moveFrontBack(const Vector2& value)
     {
-        this->setPosition(dt*(actuelposition + velocity_));
+        //this->setPosition(dt*(actuelposition + velocity_));
     }
 
     /**

Modified: code/branches/3DPacman_FS18/src/modules/Pacman/PacmanGhost.h
===================================================================
--- code/branches/3DPacman_FS18/src/modules/Pacman/PacmanGhost.h	2018-03-29 16:23:28 UTC (rev 11844)
+++ code/branches/3DPacman_FS18/src/modules/Pacman/PacmanGhost.h	2018-03-31 22:12:17 UTC (rev 11845)
@@ -53,6 +53,8 @@
             virtual void rotateYaw(const Vector2& value);
             virtual void rotatePitch(const Vector2& value);
             virtual void rotateRoll(const Vector2& value);
+
+            virtual void move();
             
             //virtual void resetGhost();
             /**
@@ -139,6 +141,7 @@
             int target_z = 0; 
             Vector3 actuelposition;
             Vector3 velocity;
+            Vector3 resetposition;
     };
 
 }



More information about the Orxonox-commit mailing list