- Timestamp:
- Apr 21, 2019, 7:58:47 PM (5 years ago)
- File:
-
- 1 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
Note: See TracChangeset
for help on using the changeset viewer.