[Orxonox-commit 7728] r12321 - code/branches/3DPacman_FS19/src/modules/pacman

peterf at orxonox.net peterf at orxonox.net
Mon Apr 22 15:09:22 CEST 2019


Author: peterf
Date: 2019-04-22 15:09:22 +0200 (Mon, 22 Apr 2019)
New Revision: 12321

Modified:
   code/branches/3DPacman_FS19/src/modules/pacman/PacmanCyan.cc
   code/branches/3DPacman_FS19/src/modules/pacman/PacmanCyan.h
Log:
continued Cyan implementation

Modified: code/branches/3DPacman_FS19/src/modules/pacman/PacmanCyan.cc
===================================================================
--- code/branches/3DPacman_FS19/src/modules/pacman/PacmanCyan.cc	2019-04-22 12:17:58 UTC (rev 12320)
+++ code/branches/3DPacman_FS19/src/modules/pacman/PacmanCyan.cc	2019-04-22 13:09:22 UTC (rev 12321)
@@ -16,6 +16,8 @@
         this->target_x=0;
         this->target_z=15;
         this->lastPlayerPassedPoint=Vector3(70,10,-135);
+
+        this->isPatrolling = false;
           
     }
 
@@ -66,9 +68,28 @@
             while(lockmove){};
             lockmove = true;
 
+            Vector3 cyanPos=Vector3(this->target_x, 10, this->target_z);
         	
+            if(this->isPatrolling==false){
+                //we are not patrolling anymore, choose new patrol
 
-            Vector3 cyanPos=Vector3(this->target_x, 10, this->target_z);
+
+                this->nextPatrol();
+
+            }
+            else if((this->isPatrolling==true)&&(cyanPos!=this->goalPatrol)){
+
+
+
+            }
+            else if(cyanPos==this->goalPatrol){
+
+            }
+            else if(cyanPos==this->startPatrol){
+
+            }
+
+
             
 
 
@@ -77,7 +98,36 @@
         
     }
 
+    void PacmanCyan::nextPatrol(){
 
+
+        int indexRand1=rand()%67;
+                while(indexRand1==44){
+                    //new try if index is that of the position in the middle
+                    indexRand1=rand()%67;
+                }
+
+                int indexRand2=rand()%67;
+                while((indexRand2==44)||(indexRand2==indexRand1)){
+                    //new try if 2nd index is same as first one or is index
+                    // of position in the middle
+
+                    indexRand2=rand()%67;
+                }
+
+
+
+
+              this->startPatrol =  possibleposition[indexRand1];
+              this->goalPatrol = possibleposition[indexRand2];
+
+              Vector3 nextMovement = getShortestPath(startPatrol, goalPatrol);
+
+    }
+
+
+
+
 	void PacmanCyan::nextMove( Vector3 cyanPosP, Vector3 playerPos){
 	
         Vector3 nextTarget;
@@ -87,5 +137,20 @@
 	   setNewTargetGhost(nextTarget);
 	}
 
+    struct PacmanCyan::PatrolPosition{
+        //we need to check if PacmanCyan already passed the goal resp. start patrol point
 
+    public:
+
+        Vector3 position;
+        bool visitedPoint;
+
+        PatrolPosition(Vector3 positionP){
+            this->position=positionP;
+            visitedPoint=false;
+        }
+
+    };
+
+
 }
\ No newline at end of file

Modified: code/branches/3DPacman_FS19/src/modules/pacman/PacmanCyan.h
===================================================================
--- code/branches/3DPacman_FS19/src/modules/pacman/PacmanCyan.h	2019-04-22 12:17:58 UTC (rev 12320)
+++ code/branches/3DPacman_FS19/src/modules/pacman/PacmanCyan.h	2019-04-22 13:09:22 UTC (rev 12321)
@@ -19,8 +19,17 @@
 
   			void nextMove( Vector3 cyanPosP, Vector3 playerPos);
 
+  			bool isPatrolling;
 
+  			void nextPatrol();
 
+  			Vector3 startPatrol;
+  			Vector3 goalPatrol;
+
+  			struct PatrolPosition;
+
+
+
 	};
 
 }



More information about the Orxonox-commit mailing list