Changeset 11903 for code/branches/3DPacman_FS18/src
- Timestamp:
- Apr 25, 2018, 1:06:00 PM (7 years ago)
- Location:
- code/branches/3DPacman_FS18/src/modules
- Files:
-
- 1 deleted
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/3DPacman_FS18/src/modules/pacman/PacmanGhost.cc
r11900 r11903 118 118 else{ 119 119 if(findpos(actuelposition,possibleposition[0])){ 120 setnewTarget(1); 121 } 122 else if(findpos(actuelposition,possibleposition[1])){ 123 setnewTarget(0,2); 124 } 125 else if(findpos(actuelposition,possibleposition[2])){ 126 setnewTarget(1,3); 127 } 128 else if(findpos(actuelposition,possibleposition[3])){ 129 setnewTarget(2,4,5); 130 } 131 else if(findpos(actuelposition,possibleposition[4])){ 132 setnewTarget(3,6); 133 } 134 else if(findpos(actuelposition,possibleposition[5])){ 135 setnewTarget(3,7); 136 } 137 else if(findpos(actuelposition,possibleposition[6])){ 138 setnewTarget(4); 139 } 140 else if(findpos(actuelposition,possibleposition[7])){ 141 setnewTarget(5); 142 } 143 144 145 else{ 146 } //End of Position table 147 } 148 149 } 150 151 void PacmanGhost::setnewTarget(int firstdec){ 152 decision = rand()%1; 153 switch(decision){ 154 case 0: 155 this->target_x = possibleposition[firstdec].x; 156 this->target_z = possibleposition[firstdec].z; 157 this->ismoving = true; 158 break; 159 } 160 } 161 162 void PacmanGhost::setnewTarget(int firstdec, int seconddec){ 163 decision = rand()%2; 164 switch(decision){ 165 case 0: 166 this->target_x = possibleposition[firstdec].x; 167 this->target_z = possibleposition[firstdec].z; 168 this->ismoving = true; 169 break; 170 case 1: 171 this->target_x = possibleposition[seconddec].x; 172 this->target_z = possibleposition[seconddec].z; 173 this->ismoving = true; 174 break; 175 } 176 } 177 178 void PacmanGhost::setnewTarget(int firstdec, int seconddec, int thirddec){ 179 decision = rand()%3; 180 switch(decision){ 181 case 0: 182 this->target_x = possibleposition[firstdec].x; 183 this->target_z = possibleposition[firstdec].z; 184 this->ismoving = true; 185 break; 186 case 1: 187 this->target_x = possibleposition[seconddec].x; 188 this->target_z = possibleposition[seconddec].z; 189 this->ismoving = true; 190 break; 191 case 2: 192 this->target_x = possibleposition[thirddec].x; 193 this->target_z = possibleposition[thirddec].z; 194 this->ismoving = true; 195 break; 196 } 197 } 198 199 void PacmanGhost::setnewTarget(int firstdec, int seconddec, int thirddec, int fourthdec){ 200 decision = rand()%4; 201 switch(decision){ 202 case 0: 203 this->target_x = possibleposition[firstdec].x; 204 this->target_z = possibleposition[firstdec].z; 205 this->ismoving = true; 206 break; 207 case 1: 208 this->target_x = possibleposition[seconddec].x; 209 this->target_z = possibleposition[seconddec].z; 210 this->ismoving = true; 211 break; 212 case 2: 213 this->target_x = possibleposition[thirddec].x; 214 this->target_z = possibleposition[thirddec].z; 215 this->ismoving = true; 216 break; 217 case 3: 218 this->target_x = possibleposition[fourthdec].x; 219 this->target_z = possibleposition[fourthdec].z; 220 this->ismoving = true; 221 break; 222 } 223 } 224 225 226 227 void PacmanGhost::move(float dt, Vector3 actuelposition, Vector3 velocity){ 228 this->setPosition(Vector3(actuelposition.x+20*velocity.x*dt,10,actuelposition.z+20*velocity.z*dt)); 229 } 230 231 bool PacmanGhost::findpos(Vector3 one, Vector3 other){ 232 if((abs(one.x - other.x)<0.1) && (abs(one.z - other.z)<0.1)) return true; 233 return false; 234 } 235 236 void PacmanGhost::resetGhost(){ 237 this->setPosition(resetposition); 238 } 239 } 240 241 /* 242 //Check on which position ghost has arrived and set new target 243 else{ 244 if(findpos(actuelposition,possibleposition[0])){ 120 245 decision = rand()%1; 121 246 switch(decision){ … … 239 364 else{ 240 365 } //End of Position table 241 }242 243 }244 245 246 void PacmanGhost::move(float dt, Vector3 actuelposition, Vector3 velocity){247 this->setPosition(Vector3(actuelposition.x+20*velocity.x*dt,10,actuelposition.z+20*velocity.z*dt));248 }249 250 bool PacmanGhost::findpos(Vector3 one, Vector3 other){251 if((abs(one.x - other.x)<0.1) && (abs(one.z - other.z)<0.1)) return true;252 return false;253 }254 255 void PacmanGhost::resetGhost(){256 this->setPosition(resetposition);257 }258 } -
code/branches/3DPacman_FS18/src/modules/pacman/PacmanGhost.h
r11900 r11903 51 51 void resetGhost(); 52 52 53 void setnewTarget(int firstdec); 54 void setnewTarget(int firstdec, int seconddec); 55 void setnewTarget(int firstdec, int seconddec, int thirddec); 56 void setnewTarget(int firstdec, int seconddec, int thirddec, int fourthdec); 57 58 53 59 bool findpos(Vector3 one, Vector3 other); 54 60
Note: See TracChangeset
for help on using the changeset viewer.