I'm new to Greenfoot (learning it so that I can teach it to my kids) and I'm working on a little scenario where a bug moves away from its leaf pile, looks around for food, and when it finds it, it heads straight back home to drop it off.
Everything is working correctly - I'm using the following code to turn the bug towards its home leaf pile once it's full of chicken, but instead of turning exactly toward the pile, it only turns generally towards it - it'll walk in a straight line for a while, then it turns again to correct its angle, and then walks straight to the leaf pile.
This isn't a problem for this little scenario - I actually kind of like the non-direct path that the little bugs take, but I can see it being an issue later on.
Is this the way turnTowards works, or am I missing something?
List<LeafPile> allPiles = getWorld().getObjects(LeafPile.class); for(LeafPile pile : allPiles){ int pileID = pile.queryID(); if(pileID == getHomeID()){ turnTowards(pile.getX(), pile.getY()); } }