public class Ant extends Actor
{
private double xSpeed;
private double ySpeed;
private int goodCalorie;
private int badCalorie;
private double exactX;
private double exactY;
public Ant (double xSpeed, double ySpeed)
{
goodCalorie = 200;
badCalorie = 100;
this.xSpeed = xSpeed;
this.ySpeed = ySpeed;
}
protected void addedToWorld (World myWorld)
{
exactX = getX();
exactY = getY();
}
/**
* Act - do whatever the Ant wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
exactX += xSpeed;
exactY += ySpeed;
setLocation ( (int) exactX, (int) exactY );
if (isAtEdge())
{
setLocation( (int) exactX, (int) exactY );
}
}
}
