Skip to content

Instantly share code, notes, and snippets.

@deviancee
Created May 4, 2014 14:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deviancee/5eccd2531f4fc6c805dd to your computer and use it in GitHub Desktop.
Save deviancee/5eccd2531f4fc6c805dd to your computer and use it in GitHub Desktop.
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