- Timestamp:
- Apr 20, 2019, 5:22:51 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/3DPacman_FS19/src/modules/pacman/PacmanRed.cc
r12304 r12316 4 4 #include "core/CoreIncludes.h" 5 5 #include "BulletDynamics/Dynamics/btRigidBody.h" 6 7 6 8 7 9 namespace orxonox{ … … 12 14 13 15 RegisterObject(PacmanRed); 16 this->target_x=0; 17 this->target_z=15; 18 this->lastPlayerPassedPoint=Vector3(70,10,-135); 14 19 15 20 } … … 25 30 } 26 31 32 /*void PacmanRed::setPlayerPos(Vector3 _playerPos) 33 { 34 this->playerPos = _playerPos; 35 }*/ 36 37 bool PacmanRed::jeanfindpos(Vector3 one, Vector3 other){ 38 if((abs(one.x - other.x)<15) && (abs(one.y - other.y)<15) && (abs(one.z - other.z)<15)) return true; 39 return false; 40 } 41 27 42 void PacmanRed::tick(float dt) 28 43 { … … 30 45 31 46 this->actuelposition = this->getPosition(); 47 48 for(int u=0; u < 67; u++){//always check if player passed a point 49 if(jeanfindpos(this->getPlayerPos(), possibleposition[u])){ 50 this->lastPlayerPassedPoint=possibleposition[u]; 51 } 52 } 53 32 54 33 55 //Stop, if target arrived … … 55 77 56 78 //do red behavior 79 //Use target_x and target_z for position of red pacman 57 80 58 Vector3 purePos = setPureArrayPos(this->actuelposition); 59 //find nearest position on the map to red pos if pacman does not move, 60 //i.e. reached a point on the map 61 //Why not simply use target_x and target_z ?????? 81 Vector3 redPos=Vector3(this->target_x, 10, this->target_z); 82 //nextMove(this->getPlayerPos(), redPos); 62 83 63 nextMove(purePos, player.actuelposition);64 //how do we access the PLAYER variable ??????65 84 66 //also, player.lastPassedPoint is maybe better 85 if(this->actuelposition!=lastPlayerPassedPoint){ 86 //std::cout<<this->target_x<<" "<<this->target_z<<endl; 87 std::cout<<redPos<<endl; 88 std::cout<<this->lastPlayerPassedPoint<<endl; 89 //getShortestPath(Vector3(-215,10,-195),Vector3(70,10,-135)); 90 //getShortestPath(redPos, lastPlayerPassedPoint); 91 nextMove(redPos, lastPlayerPassedPoint); 92 }/* 93 else{// red pacman is at lastPlayerPassedPoint 94 nextMove(this->getPlayerPos(), redPos); 95 }*/ 96 97 //setNewTargetRed(Vector3(70,10,-85)); 98 //std::cout<<this->target_x<<" "<<target_z<<endl; 99 //std::cout<<"meuh"<<endl; 100 //std::cout<<this->actuelposition; 101 102 lockmove=false; //NEVER FORGET THIS ONE !!!!!!! 67 103 } 68 104 … … 78 114 79 115 80 void PacmanRed::nextMove(Vector3 playerPos, Vector3 redPos){ 81 Vector3 nextTarget; 116 void PacmanRed::nextMove( Vector3 redPosP, Vector3 playerPos){ 117 118 Vector3 nextTarget; 82 119 83 nextTarget = getShortestPath(playerPos, redPos);120 nextTarget = getShortestPath(redPosP, playerPos); 84 121 85 setNewTargetRed(nextTarget);122 setNewTargetRed(nextTarget); 86 123 } 87 124
Note: See TracChangeset
for help on using the changeset viewer.