Hey guys
i need your help. This is the Code for a class which is supposed to turn towards an instance of the "ressourcen" class.
My debugger shows me that the code works for the most part. The console always shows the right numbers and the if-methode within the while-methode always gets triggered in the right moment and even the System.out.print()-methodes in the if-methode are working correctly.
But the turnTowards()-methode after those is just not working.
This is the full class:
import greenfoot.*;
public class Arbeiter_smart extends Actor
{
private int Xloc;
private int Yloc;
Ressourcen ressourcen;
public void act()
{
// Add your action code here.
}
public void findRessources_Fnole()
{
int Xloc = getX();
int Yloc = getY();
System.out.println(Xloc);
System.out.println(Yloc);
int iRZ = 0;
while (iRZ < 18)
{
Actor ressourcen = (Actor)getWorld().getObjects(Ressourcen.class).get(iRZ);
int rX = ressourcen.getX();
int rY = ressourcen.getY();
System.out.println(rX);
System.out.println(rY);
System.out.println((rX - Xloc)*(rX - Xloc) + (Yloc - rY)*(Yloc - rY));
if(((rX - Xloc)*(rX - Xloc) + (Yloc - rY)*(Yloc - rY)) <= 10000)
{
System.out.println(rX);
System.out.println(rY);
turnTowards(23,356);
}
else
{
iRZ++;
}
}
}
public void turn()
{turnTowards(23, 235);
}
}

