[Orxonox-commit 7730] r12323 - code/branches/3DPacman_FS19/src/modules/pacman

peterf at orxonox.net peterf at orxonox.net
Thu Apr 25 14:45:27 CEST 2019


Author: peterf
Date: 2019-04-25 14:45:27 +0200 (Thu, 25 Apr 2019)
New Revision: 12323

Modified:
   code/branches/3DPacman_FS19/src/modules/pacman/PacmanBrown.cc
   code/branches/3DPacman_FS19/src/modules/pacman/PacmanGhost.cc
   code/branches/3DPacman_FS19/src/modules/pacman/PacmanRed.cc
Log:
continued brown

Modified: code/branches/3DPacman_FS19/src/modules/pacman/PacmanBrown.cc
===================================================================
--- code/branches/3DPacman_FS19/src/modules/pacman/PacmanBrown.cc	2019-04-24 20:38:07 UTC (rev 12322)
+++ code/branches/3DPacman_FS19/src/modules/pacman/PacmanBrown.cc	2019-04-25 12:45:27 UTC (rev 12323)
@@ -91,8 +91,38 @@
         	//put everything needed here
 
             Vector3 brownPos=Vector3(this->target_x, 10, this->target_z);
+            std::cout<<brownPos<<endl;
 
-            if(absoluteDistance(this->lastPlayerPassedPoint, this->actuelposition)<50){
+            
+            if(this->isFleeing==true){
+                if(findpos(brownPos, Vector3(-215,10,-195))){
+                    this->isFleeing=false;
+                    //Vector3 nextMoveP = getShortestPath(brownPos, this->lastPlayerPassedPoint);
+                    //this->setNewTargetGhost(nextMoveP);
+                }
+                else{
+                    Vector3 nextMoveP = getShortestPath(brownPos, Vector3(-215,10,-195));
+                    this->setNewTargetGhost(nextMoveP);
+                }
+
+            }
+            else {
+                    Vector3 arrayPlaNeig[4];
+
+                    findNeighboorPositions(this->lastPlayerPassedPoint, arrayPlaNeig, possibleposition);
+                    if(isAdjacentToPlayerLastPastPoint(brownPos, arrayPlaNeig)){
+                        this->isFleeing=true;
+                    }
+                    else{
+                        Vector3 nextMove = getShortestPath(brownPos, this->lastPlayerPassedPoint);        
+                        setNewTargetGhost(nextMove);
+                    }
+
+            }
+            std::cout<<this->isFleeing<<endl;
+
+
+            /*if(absoluteDistance(this->lastPlayerPassedPoint, this->actuelposition)<50){
                 //no idea if 50 is large enough 
 
                 //if near player, flee
@@ -122,7 +152,7 @@
             if(this->isFleeing){
                 std::cout<<"fleeing"<<endl;
             }
-        }
+        }*/
 
 
 
@@ -154,9 +184,9 @@
             lockmove=false; //NEVER FORGET THIS ONE !!!
    
         }
+}
 
 
-
     bool PacmanBrown::isAdjacentToPlayerLastPastPoint(Vector3 pacmanBrownPos, Vector3 arrayForNeighborPositions[]){
             //return true if brownPacman is on an adjacent position to the last
             //point visited by the player. return false otherwise.

Modified: code/branches/3DPacman_FS19/src/modules/pacman/PacmanGhost.cc
===================================================================
--- code/branches/3DPacman_FS19/src/modules/pacman/PacmanGhost.cc	2019-04-24 20:38:07 UTC (rev 12322)
+++ code/branches/3DPacman_FS19/src/modules/pacman/PacmanGhost.cc	2019-04-25 12:45:27 UTC (rev 12323)
@@ -710,7 +710,7 @@
                           }
             else if(findpos(actuelposition,possibleposition[59])){
                 adjacentVertices[0]=&listOfVerticesP2[58]; //graphVertex(possibleposition[58]);
-                adjacentVertices[1]=&listOfVerticesP2[59]; //graphVertex(possibleposition[59]);
+                adjacentVertices[1]=&listOfVerticesP2[60]; //graphVertex(possibleposition[59]);
                 adjacentVertices[2]=&listOfVerticesP2[63]; //graphVertex(possibleposition[63]);
                           }
             else if(findpos(actuelposition,possibleposition[60])){

Modified: code/branches/3DPacman_FS19/src/modules/pacman/PacmanRed.cc
===================================================================
--- code/branches/3DPacman_FS19/src/modules/pacman/PacmanRed.cc	2019-04-24 20:38:07 UTC (rev 12322)
+++ code/branches/3DPacman_FS19/src/modules/pacman/PacmanRed.cc	2019-04-25 12:45:27 UTC (rev 12323)
@@ -44,9 +44,13 @@
         this->actuelposition = this->getPosition();
 
         for(int u=0; u < 67; u++){//always check if player passed a point
-            if(jeanfindpos(this->getPlayerPos(), possibleposition[u])){
-            this->lastPlayerPassedPoint=possibleposition[u];
-                    }
+            //if(possibleposition[u]!=Vector3(0,10,15)){
+                if(jeanfindpos(this->getPlayerPos(), possibleposition[u])){
+                    //if(!findpos(possibleposition[u],Vector3(0,10,15))){
+                this->lastPlayerPassedPoint=possibleposition[u];
+                            }
+                        //}
+                //}
             }
 
 
@@ -124,7 +128,9 @@
                 std::cout<<this->pointInFrontOfPlayer<<endl;
                 std::cout<<this->actuelposition<<endl;*/
 
+                //if(!findpos(pointInFrontOfPlayer, Vector3(0,10,15))){
                 nextMove(lastPlayerPassedPoint, pointInFrontOfPlayer);
+                    //}
                 std::cout<<"ogslodm"<<endl;
             }
 



More information about the Orxonox-commit mailing list