java.lang.Objectgreenfoot.Actor
Creature
public class Creature
A creature in a simulation. The creature has a known home. It can move and head towards or away from home. Movement of the creature is arranged by storing a deltaX/deltaY pair: the offsets in the x/y direction that the creature will move in the next step. The value for these is capped by the SPEED constant: the delta values will always be in the range [-SPEED..SPEED].
Constructor Summary | |
---|---|
Creature()
|
Method Summary | |
---|---|
AntHill |
getHomeHill()
Get the home hill of this creature. |
void |
headTowards(greenfoot.Actor target)
Adjust the walking direction to head towards the given co-ordinates. |
void |
randomWalk()
Walk around randomly. |
void |
setHomeHill(AntHill homeHill)
Set the home hill of this creature. |
void |
walk()
Walk forward in the current direction with the current speed. |
void |
walkAwayFromHome()
Try to walk away from home. |
void |
walkTowardsHome()
Try to walk home. |
Methods inherited from class greenfoot.Actor |
---|
act, addedToWorld, getImage, getIntersectingObjects, getNeighbours, getObjectsAtOffset, getObjectsInRange, getOneIntersectingObject, getOneObjectAtOffset, getRotation, getWorld, getX, getY, intersects, setImage, setImage, setLocation, setRotation |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Creature()
Method Detail |
---|
public AntHill getHomeHill()
public void headTowards(greenfoot.Actor target)
public void randomWalk()
public void setHomeHill(AntHill homeHill)
public void walk()
public void walkAwayFromHome()
public void walkTowardsHome()