Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 12321


Ignore:
Timestamp:
Apr 22, 2019, 3:09:22 PM (5 years ago)
Author:
peterf
Message:

continued Cyan implementation

Location:
code/branches/3DPacman_FS19/src/modules/pacman
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/3DPacman_FS19/src/modules/pacman/PacmanCyan.cc

    r12320 r12321  
    1717        this->target_z=15;
    1818        this->lastPlayerPassedPoint=Vector3(70,10,-135);
     19
     20        this->isPatrolling = false;
    1921         
    2022    }
     
    6769            lockmove = true;
    6870
     71            Vector3 cyanPos=Vector3(this->target_x, 10, this->target_z);
    6972               
     73            if(this->isPatrolling==false){
     74                //we are not patrolling anymore, choose new patrol
    7075
    71             Vector3 cyanPos=Vector3(this->target_x, 10, this->target_z);
     76
     77                this->nextPatrol();
     78
     79            }
     80            else if((this->isPatrolling==true)&&(cyanPos!=this->goalPatrol)){
     81
     82
     83
     84            }
     85            else if(cyanPos==this->goalPatrol){
     86
     87            }
     88            else if(cyanPos==this->startPatrol){
     89
     90            }
     91
     92
    7293           
    7394
     
    7798       
    7899    }
     100
     101    void PacmanCyan::nextPatrol(){
     102
     103
     104        int indexRand1=rand()%67;
     105                while(indexRand1==44){
     106                    //new try if index is that of the position in the middle
     107                    indexRand1=rand()%67;
     108                }
     109
     110                int indexRand2=rand()%67;
     111                while((indexRand2==44)||(indexRand2==indexRand1)){
     112                    //new try if 2nd index is same as first one or is index
     113                    // of position in the middle
     114
     115                    indexRand2=rand()%67;
     116                }
     117
     118
     119
     120
     121              this->startPatrol =  possibleposition[indexRand1];
     122              this->goalPatrol = possibleposition[indexRand2];
     123
     124              Vector3 nextMovement = getShortestPath(startPatrol, goalPatrol);
     125
     126    }
     127
     128
    79129
    80130
     
    88138        }
    89139
     140    struct PacmanCyan::PatrolPosition{
     141        //we need to check if PacmanCyan already passed the goal resp. start patrol point
     142
     143    public:
     144
     145        Vector3 position;
     146        bool visitedPoint;
     147
     148        PatrolPosition(Vector3 positionP){
     149            this->position=positionP;
     150            visitedPoint=false;
     151        }
     152
     153    };
     154
    90155
    91156}
  • code/branches/3DPacman_FS19/src/modules/pacman/PacmanCyan.h

    r12320 r12321  
    2020                        void nextMove( Vector3 cyanPosP, Vector3 playerPos);
    2121
     22                        bool isPatrolling;
     23
     24                        void nextPatrol();
     25
     26                        Vector3 startPatrol;
     27                        Vector3 goalPatrol;
     28
     29                        struct PatrolPosition;
     30
    2231
    2332
Note: See TracChangeset for help on using the changeset viewer.