I'm teaching my class the basics in Java through the use of Greenfoot, which is awesome by the way. I'm having a problem adding code to World > Ground - I don't know the right place in the editor to add the code.
Here are the instructions we are following... (see link below)
What do we want to do with Snake? We want it to move to the Wombat. We’re going to do that by
using a new function of Greenfoot 2.2, which is turnTowards(int x, int y). But for that method, we
need the coordinates of the Wombat. We are going to store that in the Ground class.
Add this to the Ground:
private double userX;
private double userY;
Give them a value in the action Ground():
userX = user.getExactX();
userY = user.getExactY();
And add the act() method to Ground:
public void act()
{
if (user != null) {
userX = user.getExactX();
userY = user.getExactY();
}
}
Now, the userX and userY doubles will automatically be updated, except for when there’s no
Wombat in the world. We use doubles instead of integers, because we imported the class
SmoothMover which is meant to use doubles as location.
Snake Avoider instructions
Is there anyone that could show me how/where this code goes in the World editor? Any help, support would be greatly appreciated.
Cheers
Joe



