[Orxonox-commit 7286] r11903 - in code/branches/3DPacman_FS18/src/modules: . pacman
dreherm at orxonox.net
dreherm at orxonox.net
Wed Apr 25 13:06:00 CEST 2018
Author: dreherm
Date: 2018-04-25 13:06:00 +0200 (Wed, 25 Apr 2018)
New Revision: 11903
Removed:
code/branches/3DPacman_FS18/src/modules/Pacman/
Modified:
code/branches/3DPacman_FS18/src/modules/pacman/PacmanGhost.cc
code/branches/3DPacman_FS18/src/modules/pacman/PacmanGhost.h
Log:
Other ghost movement
Modified: code/branches/3DPacman_FS18/src/modules/pacman/PacmanGhost.cc
===================================================================
--- code/branches/3DPacman_FS18/src/modules/pacman/PacmanGhost.cc 2018-04-24 15:56:18 UTC (rev 11902)
+++ code/branches/3DPacman_FS18/src/modules/pacman/PacmanGhost.cc 2018-04-25 11:06:00 UTC (rev 11903)
@@ -117,6 +117,131 @@
//Check on which position ghost has arrived and set new target
else{
if(findpos(actuelposition,possibleposition[0])){
+ setnewTarget(1);
+ }
+ else if(findpos(actuelposition,possibleposition[1])){
+ setnewTarget(0,2);
+ }
+ else if(findpos(actuelposition,possibleposition[2])){
+ setnewTarget(1,3);
+ }
+ else if(findpos(actuelposition,possibleposition[3])){
+ setnewTarget(2,4,5);
+ }
+ else if(findpos(actuelposition,possibleposition[4])){
+ setnewTarget(3,6);
+ }
+ else if(findpos(actuelposition,possibleposition[5])){
+ setnewTarget(3,7);
+ }
+ else if(findpos(actuelposition,possibleposition[6])){
+ setnewTarget(4);
+ }
+ else if(findpos(actuelposition,possibleposition[7])){
+ setnewTarget(5);
+ }
+
+
+ else{
+ } //End of Position table
+ }
+
+ }
+
+ void PacmanGhost::setnewTarget(int firstdec){
+ decision = rand()%1;
+ switch(decision){
+ case 0:
+ this->target_x = possibleposition[firstdec].x;
+ this->target_z = possibleposition[firstdec].z;
+ this->ismoving = true;
+ break;
+ }
+ }
+
+ void PacmanGhost::setnewTarget(int firstdec, int seconddec){
+ decision = rand()%2;
+ switch(decision){
+ case 0:
+ this->target_x = possibleposition[firstdec].x;
+ this->target_z = possibleposition[firstdec].z;
+ this->ismoving = true;
+ break;
+ case 1:
+ this->target_x = possibleposition[seconddec].x;
+ this->target_z = possibleposition[seconddec].z;
+ this->ismoving = true;
+ break;
+ }
+ }
+
+ void PacmanGhost::setnewTarget(int firstdec, int seconddec, int thirddec){
+ decision = rand()%3;
+ switch(decision){
+ case 0:
+ this->target_x = possibleposition[firstdec].x;
+ this->target_z = possibleposition[firstdec].z;
+ this->ismoving = true;
+ break;
+ case 1:
+ this->target_x = possibleposition[seconddec].x;
+ this->target_z = possibleposition[seconddec].z;
+ this->ismoving = true;
+ break;
+ case 2:
+ this->target_x = possibleposition[thirddec].x;
+ this->target_z = possibleposition[thirddec].z;
+ this->ismoving = true;
+ break;
+ }
+ }
+
+ void PacmanGhost::setnewTarget(int firstdec, int seconddec, int thirddec, int fourthdec){
+ decision = rand()%4;
+ switch(decision){
+ case 0:
+ this->target_x = possibleposition[firstdec].x;
+ this->target_z = possibleposition[firstdec].z;
+ this->ismoving = true;
+ break;
+ case 1:
+ this->target_x = possibleposition[seconddec].x;
+ this->target_z = possibleposition[seconddec].z;
+ this->ismoving = true;
+ break;
+ case 2:
+ this->target_x = possibleposition[thirddec].x;
+ this->target_z = possibleposition[thirddec].z;
+ this->ismoving = true;
+ break;
+ case 3:
+ this->target_x = possibleposition[fourthdec].x;
+ this->target_z = possibleposition[fourthdec].z;
+ this->ismoving = true;
+ break;
+ }
+ }
+
+
+
+ void PacmanGhost::move(float dt, Vector3 actuelposition, Vector3 velocity){
+ this->setPosition(Vector3(actuelposition.x+20*velocity.x*dt,10,actuelposition.z+20*velocity.z*dt));
+ }
+
+ bool PacmanGhost::findpos(Vector3 one, Vector3 other){
+ if((abs(one.x - other.x)<0.1) && (abs(one.z - other.z)<0.1)) return true;
+ return false;
+ }
+
+ void PacmanGhost::resetGhost(){
+ this->setPosition(resetposition);
+ }
+}
+
+/*
+//Check on which position ghost has arrived and set new target
+ else{
+ if(findpos(actuelposition,possibleposition[0])){
decision = rand()%1;
switch(decision){
case 0:
@@ -237,22 +362,4 @@
else{
- } //End of Position table
- }
-
- }
-
-
- void PacmanGhost::move(float dt, Vector3 actuelposition, Vector3 velocity){
- this->setPosition(Vector3(actuelposition.x+20*velocity.x*dt,10,actuelposition.z+20*velocity.z*dt));
- }
-
- bool PacmanGhost::findpos(Vector3 one, Vector3 other){
- if((abs(one.x - other.x)<0.1) && (abs(one.z - other.z)<0.1)) return true;
- return false;
- }
-
- void PacmanGhost::resetGhost(){
- this->setPosition(resetposition);
- }
-}
+ } //End of Position table
\ No newline at end of file
Modified: code/branches/3DPacman_FS18/src/modules/pacman/PacmanGhost.h
===================================================================
--- code/branches/3DPacman_FS18/src/modules/pacman/PacmanGhost.h 2018-04-24 15:56:18 UTC (rev 11902)
+++ code/branches/3DPacman_FS18/src/modules/pacman/PacmanGhost.h 2018-04-25 11:06:00 UTC (rev 11903)
@@ -50,6 +50,12 @@
void resetGhost();
+ void setnewTarget(int firstdec);
+ void setnewTarget(int firstdec, int seconddec);
+ void setnewTarget(int firstdec, int seconddec, int thirddec);
+ void setnewTarget(int firstdec, int seconddec, int thirddec, int fourthdec);
+
+
bool findpos(Vector3 one, Vector3 other);
inline void setResetPosition(Vector3 rpos)
More information about the Orxonox-commit
mailing list