-
-
Save deviancee/5eccd2531f4fc6c805dd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if(animal.equals("wolf")){ | |
for(int i=0; i<app.wolvesCoords.length; i++){ | |
int tempdistance = (int)Math.round(Math.sqrt(Math.pow(x-app.wolvesCoords[i][0],2)+Math.pow(y-app.wolvesCoords[i][1],2))); | |
int changex=app.wolvesCoords[i][0]; | |
int changey=app.wolvesCoords[i][1]; | |
if((changex==x)&&(changey==y)) continue; | |
for(int l=0; l<animals.length; l++){ | |
if(tempdistance<animals[l][2]){ | |
if(l!=animals.length){ | |
changex=animals[l][0]; | |
changey=animals[l][1]; | |
int tempdistance2=animals[l][2]; | |
animals[l][0]=app.wolvesCoords[i][0]; | |
animals[l][1]=app.wolvesCoords[i][1]; | |
animals[l][2]=tempdistance; | |
tempdistance=tempdistance2; | |
} | |
else{ | |
animals[l][0]=app.wolvesCoords[i][0]; | |
animals[l][1]=app.wolvesCoords[i][1]; | |
animals[l][2]=tempdistance; | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment