Changeset 12320 for code/branches/3DPacman_FS19/src
- Timestamp:
- Apr 22, 2019, 2:17:58 PM (6 years ago)
- 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 9 9 PacmanRed.cc 10 10 PacmanPink.cc 11 PacmanBrown.cc 12 PacmanCyan.cc 11 13 ) 12 14 -
code/branches/3DPacman_FS19/src/modules/pacman/PacmanBrown.cc
r12304 r12320 25 25 } 26 26 27 28 int 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 } 27 38 28 39 … … 59 70 //put everything needed here 60 71 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))){ 62 107 //if fleeing, then go to corner map if not already there 63 108 fleeMode(); … … 82 127 } 83 128 84 } 129 }*/ 130 lockmove=false; //NEVER FORGET THIS ONE !!! 85 131 86 132 } 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){ 100 152 101 153 Vector3 differenceVector= Vector3(abs(goal.x-start.x), 0,abs(goal.z-start.z)); 102 154 103 155 return differenceVector.x+differenceVector.z; 104 } 105 106 void setNewTargetBrown(Vector3 goalToGo){156 }*/ 157 158 /*void setNewTargetBrown(Vector3 goalToGo){ 107 159 108 160 this->target_x = goalToGo.x; 109 161 this->target_z = goalToGo.z; 110 162 this->ismoving = true; 111 } 112 113 114 115 intabsoluteDistance(Vector3 pos1, Vector3 pos2){163 }*/ 164 165 166 167 /*int PacmanBrown::absoluteDistance(Vector3 pos1, Vector3 pos2){ 116 168 117 169 … … 120 172 diffVector.y=pos2-pos1; //should always be 0 121 173 diffVector.z=pos2-pos1; 122 int result = sqrt( diffVector.x²+diffVector.z²);174 int result = sqrt((diffVector.x)*(diffVector.x)+(diffVector.z)*(diffVector.z)); 123 175 return result; 124 } 125 126 127 void fleeMode(){ //flees to corner of the map176 }*/ 177 178 179 /*void fleeMode(){ //flees to corner of the map 128 180 129 181 Vector3 cornerPos = Vector3(-215,10,-195); //let's take this. We can still change 130 182 Vector3 nextMove = getShortestPath(this->actuelposition, cornerPos); 131 setNewTarget Brown(nextMove);132 133 / *//while(this->actuelposition!=cornerPos){183 setNewTargetGhost(nextMove); 184 185 //while(this->actuelposition!=cornerPos){ 134 186 135 187 continue moving and each time find next point to go until 136 188 we reach the corner 137 } */138 } 139 140 141 Vector3 goAdjacentOfPlayer(Vector neighboorsOfPlayer[]){189 } 190 }*/ 191 192 193 /*Vector3 goAdjacentOfPlayer(Vector neighboorsOfPlayer[]){ 142 194 //find ,nearest to brown, player neighboor 143 195 … … 171 223 return chosenNeighbor; 172 224 173 } 174 175 176 Vector3 findPlayerNeighboorNearestToPacman(Vector3 neighboorArray[]){225 }*/ 226 227 228 /*Vector3 findPlayerNeighboorNearestToPacman(Vector3 neighboorArray[]){ 177 229 //uh, i think it does the same think as the function above 178 230 … … 203 255 return nextMove; 204 256 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 29 29 30 30 31 Vector3 goAdjacentOfPlayer(Vector neighboorsOfPlayer[]);31 Vector3 goAdjacentOfPlayer(Vector3 neighboorsOfPlayer[]); 32 32 //they both do the same -_- 33 33 Vector3 findPlayerNeighboorNearestToPacman(Vector3 neighboorArray); 34 35 bool isFleeing; 34 36 35 37 -
code/branches/3DPacman_FS19/src/modules/pacman/PacmanGhost.h
r12319 r12320 37 37 38 38 #include "Pacman.h" 39 #include "GetShortestPathAlgorithm.h"39 //#include "GetShortestPathAlgorithm.h" 40 40 41 41 namespace orxonox {
Note: See TracChangeset
for help on using the changeset viewer.