Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 12320 for code


Ignore:
Timestamp:
Apr 22, 2019, 2:17:58 PM (5 years ago)
Author:
peterf
Message:

began PacmanBrown and Cyan implementation

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

Legend:

Unmodified
Added
Removed
  • code/branches/3DPacman_FS19/src/modules/pacman/CMakeLists.txt

    r12319 r12320  
    99  PacmanRed.cc
    1010  PacmanPink.cc
     11  PacmanBrown.cc
     12  PacmanCyan.cc
    1113)
    1214
  • code/branches/3DPacman_FS19/src/modules/pacman/PacmanBrown.cc

    r12304 r12320  
    2525    }
    2626
     27
     28int PacmanBrown::absoluteDistance(Vector3 pos1, Vector3 pos2){
     29
     30
     31        Ogre::Vector3 diffVector;
     32        diffVector.x=pos2.x-pos1.x;
     33        diffVector.y=pos2.y-pos1.y; //should always be 0
     34        diffVector.z=pos2.z-pos1.z;
     35        int result = sqrt((diffVector.x)*(diffVector.x)+(diffVector.z)*(diffVector.z));
     36        return result;
     37    }
    2738
    2839
     
    5970                //put everything needed here
    6071
    61                 if((this->fleeing==true)&&(this->actuelposition!=(-215,10,-195))){
     72            Vector3 brownPos=Vector3(this->target_x, 10, this->target_z);
     73
     74            if(absoluteDistance(this->lastPlayerPassedPoint, this->actuelposition)<50){
     75                //no idea if 50 is large enough
     76
     77                //if near player, flee
     78
     79                this->isFleeing=true;
     80                Vector3 nextMove=getShortestPath( brownPos,Vector3(-215, 10, -195));
     81                setNewTargetGhost(nextMove);
     82
     83            }
     84
     85            else if((this->isFleeing==true)&&(brownPos!=Vector3(-215,10,-195))){
     86                //if fleeing, continue to flee
     87             Vector3 nextMove = getShortestPath(brownPos, Vector3(-215, 10, -195));
     88             setNewTargetGhost(nextMove);
     89        }
     90            else if ((this->isFleeing==true)&&(brownPos==Vector3(-215,10,-195))){
     91                //if fleeing and reached flee point, go back near player
     92            this->isFleeing=false;
     93            Vector3 nextMove = getShortestPath(brownPos, this->lastPlayerPassedPoint);
     94            setNewTargetGhost(nextMove);
     95        }
     96            else{
     97                //if not fleeing and not near player, go near player
     98                Vector3 nextMove = getShortestPath(brownPos, this->lastPlayerPassedPoint);
     99            setNewTargetGhost(nextMove);
     100            }
     101        }
     102
     103
     104
     105
     106                /*if((this->fleeing==true)&&(this->actuelposition!=(-215,10,-195))){
    62107            //if fleeing, then go to corner map if not already there
    63108                        fleeMode();
     
    82127                        }
    83128
    84                 }
     129                }*/
     130            lockmove=false; //NEVER FORGET THIS ONE !!!
    85131   
    86132        }
    87        
    88     }
    89 
    90 
    91 
    92 
    93 
    94 
    95 
    96 
    97 
    98 
    99         int graphDistance(Vector3 start, Vector3 goal){
     133    }
     134
     135
     136
     137   
     138
     139
     140
     141
     142
     143
     144
     145
     146
     147
     148
     149
     150
     151        /*int graphDistance(Vector3 start, Vector3 goal){
    100152
    101153        Vector3 differenceVector= Vector3(abs(goal.x-start.x), 0,abs(goal.z-start.z));
    102154
    103155        return differenceVector.x+differenceVector.z;
    104     }
    105 
    106         void setNewTargetBrown(Vector3 goalToGo){
     156    }*/
     157
     158        /*void setNewTargetBrown(Vector3 goalToGo){
    107159
    108160                                        this->target_x = goalToGo.x;
    109161                    this->target_z = goalToGo.z;
    110162                    this->ismoving = true;
    111         }
    112 
    113 
    114 
    115         int absoluteDistance(Vector3 pos1, Vector3 pos2){
     163        }*/
     164
     165
     166
     167        /*int PacmanBrown::absoluteDistance(Vector3 pos1, Vector3 pos2){
    116168
    117169
     
    120172                diffVector.y=pos2-pos1; //should always be 0
    121173                diffVector.z=pos2-pos1;
    122                 int result = sqrt(diffVector.x²+diffVector.z²);
     174                int result = sqrt((diffVector.x)*(diffVector.x)+(diffVector.z)*(diffVector.z));
    123175                return result;
    124         }
    125 
    126 
    127         void fleeMode(){ //flees to corner of the map
     176        }*/
     177
     178
     179        /*void fleeMode(){ //flees to corner of the map
    128180
    129181                Vector3 cornerPos = Vector3(-215,10,-195); //let's take this. We can still change
    130182                Vector3 nextMove = getShortestPath(this->actuelposition, cornerPos);
    131                 setNewTargetBrown(nextMove);
    132 
    133                 /*//while(this->actuelposition!=cornerPos){
     183                setNewTargetGhost(nextMove);
     184
     185                //while(this->actuelposition!=cornerPos){
    134186       
    135187                continue moving and each time find next point to go until
    136188                we reach the corner
    137                 }*/
    138         }
    139 
    140 
    141         Vector3 goAdjacentOfPlayer(Vector neighboorsOfPlayer[]){
     189                }
     190        }*/
     191
     192
     193        /*Vector3 goAdjacentOfPlayer(Vector neighboorsOfPlayer[]){
    142194                //find ,nearest to brown, player neighboor
    143195
     
    171223                return chosenNeighbor;
    172224
    173         }
    174 
    175 
    176         Vector3 findPlayerNeighboorNearestToPacman(Vector3 neighboorArray[]){
     225        }*/
     226
     227
     228        /*Vector3 findPlayerNeighboorNearestToPacman(Vector3 neighboorArray[]){
    177229                //uh, i think it does the same think as the function above
    178230
     
    203255        return nextMove;
    204256
    205     }
    206 
    207 }
    208 
    209 
    210 
    211 
     257    }*/
     258
     259
     260
     261
     262
     263
  • code/branches/3DPacman_FS19/src/modules/pacman/PacmanBrown.h

    r12304 r12320  
    2929
    3030
    31                         Vector3 goAdjacentOfPlayer(Vector neighboorsOfPlayer[]);
     31                        Vector3 goAdjacentOfPlayer(Vector3 neighboorsOfPlayer[]);
    3232                        //they both do the same -_-
    3333                        Vector3 findPlayerNeighboorNearestToPacman(Vector3 neighboorArray);
     34
     35        bool isFleeing;
    3436
    3537
  • code/branches/3DPacman_FS19/src/modules/pacman/PacmanGhost.h

    r12319 r12320  
    3737
    3838#include "Pacman.h"
    39 #include "GetShortestPathAlgorithm.h"
     39//#include "GetShortestPathAlgorithm.h"
    4040
    4141namespace orxonox {
Note: See TracChangeset for help on using the changeset viewer.