- Timestamp:
- Apr 27, 2019, 4:49:54 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/3DPacman_FS19/src/modules/pacman/PacmanPink.cc
r12322 r12324 17 17 this->target_z=15; 18 18 this->lastPlayerPassedPoint=Vector3(0,0,0); //Vector3(70,10,-135); 19 this->pointInFrontOfPlayer=Vector3(0,0,0); 19 20 20 21 } … … 38 39 39 40 for(int u=0; u < 67; u++){//always check if player passed a point 40 if(jeanfindpos(this->getPlayerPos(), possibleposition[u])){ 41 this->lastPlayerPassedPoint=possibleposition[u];42 41 if(jeanfindpos(this->getPlayerPos(), possibleposition[u])){ 42 this->lastPlayerPassedPoint=possibleposition[u]; 43 } 43 44 } 44 45 46 int directionV = findPlayerTravDir (lastPlayerPassedPoint, this->getPlayerPos()); 47 this->pointInFrontOfPlayer=getPointInFrontOfPacman(lastPlayerPassedPoint, directionV); 48 /*std::cout<<this->pointInFrontOfPlayer<<endl; 49 std::cout<<this->lastPlayerPassedPoint<<endl;*/ 45 50 46 51 //Stop, if target arrived … … 68 73 this->ismoving=false; 69 74 } 75 else if(this->pointInFrontOfPlayer==Vector3(0,0,0)){ 76 std::cout<<"arheeuuuu"<<endl; 77 78 Vector3 pinkPos=Vector3(this->target_x, 10, this->target_z); 79 80 setNewTargetGhost(getShortestPath(pinkPos, this->lastPlayerPassedPoint)); 81 82 83 } 70 84 //Check on which position the ghost has arrived and set new target 71 85 else{ … … 74 88 75 89 Vector3 pinkPos=Vector3(this->target_x, 10, this->target_z); 90 91 //int directionV = findPlayerTravDir (lastPlayerPassedPoint, this->getPlayerPos()); 92 //this->pointInFrontOfPlayer=getPointInFrontOfPacman(lastPlayerPassedPoint, directionV); 76 93 77 94 std::cout<<this->lastPlayerPassedPoint<<endl; 78 79 int directionV = findPlayerTravDir (lastPlayerPassedPoint, this->getPlayerPos());80 this->pointInFrontOfPlayer=getPointInFrontOfPacman(lastPlayerPassedPoint, directionV);81 95 82 96 std::cout<<this->pointInFrontOfPlayer<<endl; … … 84 98 85 99 86 87 /*if(findPos(player.getPos(), player.lastPassedPoint)){88 // if player is on a point, for simplicity go to it89 Vector3 nextMove = getShortestPath(this->actuelposition, player.lastPassedPoint);90 setNewTargetPink(nextMove);91 }92 93 else{ //if player is not on a point either go to next neighboor, or if no94 //neighboor in player direction available, go to last point passed by player.95 96 int dir=findPlayerTravDir(player.lastPassedPoint, player.getPos());97 //not in other sense!98 99 Vector3[] neighboors;100 findNeighboor(player.lastPassedPoint, neighboors);101 //we need to create function that finds neighboors of player last point102 //We can use and even should use the part of the tick random function103 // that determines the neighboors. But array neighboor should be in form104 // south-west-north-east respectively to array index.105 106 for(int s=0; s < 4; s++){107 //find next neighboor between player and player.lastPassedPoint108 if((neighboors[s]!=NULL)&&(s==dir)){109 if(dir==0){110 Vector3 nextMove=getShortestPath(this->actuelposition, neighboors[s]);111 setNewTargetPink(nextMove);112 }113 else if(dir==1){114 Vector3 nextMove=getShortestPath(this->actuelposition, neighboors[s]);115 setNewTargetPink(nextMove);116 }117 else if(dir==2){118 Vector3 nextMove=getShortestPath(this->actuelposition, neighboors[s]);119 setNewTargetPink(nextMove);120 }121 else{//last is default122 Vector3 nextMove=getShortestPath(this->actuelposition, neighboors[s]);123 setNewTargetPink(nextMove);124 }125 }126 else{//if no further point after last player point possible127 //then simply go to this last point.128 Vector3 nextMove=getShortestPath(this->actuelposition, player.lastPassedPoint);129 setNewTargetPink(nextMove);130 }131 132 }133 134 }*/135 100 lockmove=false; 136 101 … … 149 114 Vector3 nextTarget; 150 115 151 nextTarget = getShortestPath(pinkPosP, playerPos, pointToAvoidP11); 116 if(playerPos==pointToAvoidP11){ 117 nextTarget = getShortestPath(pinkPosP, playerPos); 118 } 119 else{ 120 nextTarget = getShortestPath(pinkPosP, playerPos, pointToAvoidP11); 121 } 152 122 153 123 setNewTargetGhost(nextTarget);
Note: See TracChangeset
for help on using the changeset viewer.