Changeset 12318 for code/branches/3DPacman_FS19/src
- Timestamp:
- Apr 21, 2019, 7:58:47 PM (6 years ago)
- Location:
- code/branches/3DPacman_FS19/src/modules/pacman
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/3DPacman_FS19/src/modules/pacman/PacmanGhost.cc
r12317 r12318 241 241 return player->getWorldPosition(); 242 242 } 243 //std::cout<<"bug ??"<<endl; 243 244 return Vector3(0,0,0); //default, should not be used 244 245 … … 745 746 } 746 747 748 749 bool PacmanGhost::playerFindPos(Vector3 one, Vector3 other){ 750 if((abs(one.x - other.x)<15) && (abs(one.z - other.z)<15)) return true; 751 return false; 752 } 753 754 755 756 747 757 int PacmanGhost::findPlayerTravDir (Vector3 playerPosBefore, Vector3 playerPos){ 748 758 //return 0 for south, 1 for west, 2 for north, 3 for east 749 759 750 Vector3 difference = diffVector(playerPosBefore, playerPos); 751 752 760 761 if(playerFindPos(playerPosBefore, playerPos)){ 762 //if player is still near last crossed point 763 764 return 4; //return the last crossed point for simplicity 765 } 766 767 768 if(abs(playerPos.x-playerPosBefore.x)<14){ //player is moving vertically 769 if((playerPos.z-playerPosBefore.z)<0){//move west 770 return 0; 771 } 772 if((playerPos.z-playerPosBefore.z)>0){//move east 773 return 2; 774 } 775 } 776 777 if(abs(playerPos.z-playerPosBefore.z)<14){ //player is moving horizontally 778 if((playerPos.x-playerPosBefore.x)<0){//move south 779 return 1; 780 } 781 if((playerPos.x-playerPosBefore.x)>0){//move north 782 return 3; 783 } 784 } 785 786 787 /*Vector3 difference = diffVector(playerPosBefore, playerPos); 753 788 if((difference.z < 0)&&(difference.z>difference.x)){ //move south 754 789 … … 772 807 773 808 return 1; 774 } 809 }*/ 775 810 776 811 } … … 779 814 //return the Vector3 point that Pinky should target to 780 815 //be in front of pacman 816 817 if(indexForSWNE==4){ 818 std::cout<<"Ryukyu"<<endl; 819 return pacLasVisPos; 820 } 781 821 782 822 Vector3 listOfNeighboors[4]; … … 840 880 } 841 881 else if(findpos(pacLasVisPos,possibleposition[10])){ 882 883 if(indexForSWNE==3){ //nothing eastward 884 return pacLasVisPos; 885 } 886 842 887 listOfNeighboors[0]=possibleposition[9]; //south 843 888 listOfNeighboors[1]=possibleposition[45]; //west … … 1020 1065 } 1021 1066 else if(findpos(pacLasVisPos,possibleposition[42])){ 1067 1068 if(indexForSWNE==1){//nothing westward 1069 return pacLasVisPos; 1070 } 1071 1022 1072 listOfNeighboors[0]=possibleposition[39]; //south 1023 1073 listOfNeighboors[2]=possibleposition[59]; //north -
code/branches/3DPacman_FS19/src/modules/pacman/PacmanGhost.h
r12317 r12318 89 89 Vector3 playerPos; 90 90 91 Vector3 lastPlayerPassedPoint;/* 91 Vector3 lastPlayerPassedPoint; 92 93 Vector3 pointInFrontOfPlayer; 94 /* 95 92 96 93 97 //Vector3 pathAlgorithm; … … 120 124 Vector3 diffVector (Vector3 start, Vector3 goal); 121 125 126 bool playerFindPos(Vector3 one, Vector3 other); 127 122 128 123 129 }; -
code/branches/3DPacman_FS19/src/modules/pacman/PacmanRed.cc
r12317 r12318 17 17 this->target_z=15; 18 18 this->lastPlayerPassedPoint=Vector3(70,10,-135); 19 this->isNearPlayer=false; 19 20 20 21 } … … 42 43 void PacmanRed::tick(float dt) 43 44 { 45 std::cout<<"LemanExpress5"<<endl; 44 46 SUPER(PacmanGhost, tick, dt); 45 47 … … 52 54 } 53 55 54 56 57 /*if((playerFindPos(this->actuelposition, this->getPlayerPos()))&&(isNearPlayer==false)){ 58 isNearPlayer=true; 59 setNewTargetRed(this->getPlayerPos()); 60 } 61 else if (!(playerFindPos(this->actuelposition, this->getPlayerPos())&&(isNearPlayer==true))){ 62 isNearPlayer=false; 63 setNewTargetRed(this->pointInFrontOfPlayer); 64 }*/ 65 66 67 68 55 69 //Stop, if target arrived 56 70 if((abs(this->actuelposition.x - this->target_x)<0.5) && (abs(this->actuelposition.z - this->target_z)<0.5)){ 71 std::cout<<"LemanExpress1"<<endl; 57 72 this->ismoving = false; 58 73 } … … 60 75 //Move, if ghost hasn't arrived yet 61 76 if(this->ismoving){ 77 std::cout<<"LemanExpress2"<<endl; 62 78 if(!(abs(this->actuelposition.z-target_z)<0.5)) { 63 79 velocity = Vector3(0,0,-sgn(this->actuelposition.z-this->target_z)); … … 68 84 move(dt, actuelposition, velocity); 69 85 } 86 std::cout<<"LemanExpress4"<<endl; 70 87 } 71 88 72 89 //Check on which position the ghost has arrived and set new target 73 90 else{ 91 std::cout<<"LemanExpress3"<<endl; 74 92 75 93 while(lockmove){}; … … 83 101 84 102 int directionV = findPlayerTravDir (lastPlayerPassedPoint, this->getPlayerPos()); 103 this->pointInFrontOfPlayer=getPointInFrontOfPacman(lastPlayerPassedPoint, directionV); 85 104 86 105 87 if( this->actuelposition!=lastPlayerPassedPoint){106 if(!findpos(this->actuelposition, lastPlayerPassedPoint)){ 88 107 89 108 std::cout<<this->getPlayerPos()<<endl; 90 109 std::cout<<this->lastPlayerPassedPoint<<endl; 91 std::cout<<getPointInFrontOfPacman(lastPlayerPassedPoint, directionV)<<endl; 110 std::cout<<this->pointInFrontOfPlayer<<endl; 111 std::cout<<this->actuelposition<<endl; 92 112 nextMove(redPos, lastPlayerPassedPoint); 113 std::cout<<"hiuddi"<<endl; 93 114 } 94 else {// red pacman is at lastPlayerPassedPoint115 else if(findpos(this->actuelposition, lastPlayerPassedPoint)){// red pacman is at lastPlayerPassedPoint 95 116 96 //int directionV = findPlayerTravDir (lastPlayerPassedPoint, this->getPlayerPos()); 117 std::cout<<"dhdidjop"<<endl; 118 std::cout<<this->getPlayerPos()<<endl; 119 std::cout<<this->lastPlayerPassedPoint<<endl; 120 std::cout<<this->pointInFrontOfPlayer<<endl; 121 std::cout<<this->actuelposition<<endl; 97 122 98 Vector3 pointInFrontOfPlayer = getPointInFrontOfPacman(lastPlayerPassedPoint, directionV); 99 100 nextMove(redPos, pointInFrontOfPlayer); 101 102 //nextMove(this->getPlayerPos(), redPos); 123 nextMove(lastPlayerPassedPoint, pointInFrontOfPlayer); 124 std::cout<<"ogslodm"<<endl; 103 125 } 104 126 -
code/branches/3DPacman_FS19/src/modules/pacman/PacmanRed.h
r12316 r12318 26 26 bool jeanfindpos(Vector3 one, Vector3 other); 27 27 28 bool isNearPlayer; 29 28 30 29 31
Note: See TracChangeset
for help on using the changeset viewer.