java.lang.Objectgreenfoot.Actor
Creature
public abstract class Creature
A Creature is the base class for all alien beings in this scenario. It provides the basic abilities of creatures in this world.
Constructor Summary | |
---|---|
Creature(Ship ship)
Create a creature at its ship. |
Method Summary | |
---|---|
void |
act()
Act - must be called as part of subclass act. |
boolean |
atShip()
True if we are at our space ship. |
boolean |
atWater()
Return true if we have just seen water in front of us. |
boolean |
atWorldEdge()
Test if we are close to one of the edges of the world. |
boolean |
carryingTomato()
Check whether we are carrying a tomato. |
protected void |
dropTomato()
Drop the tomato we are carrying. |
abstract java.lang.String |
getCurrentImage()
This method must be defined in subclasses. |
void |
loadTomato()
Load a tomato onto *another* creature. |
void |
move()
Move forward roughly in the current direction. |
protected boolean |
randomChance(int percent)
Return 'true' in exactly 'percent' number of calls. |
boolean |
removeTomato()
Remove the tomato currently carried (and return true). |
boolean |
seePaint(java.lang.String color)
Check whether we can see paint of a given color where we are sitting. |
void |
spit(java.lang.String color)
Spit a drop of paint onto the ground. |
void |
turn(int angle)
Turn 'angle' degrees towards the right (clockwise). |
void |
turnHome()
Turn in the direction facing the home ship. |
Methods inherited from class greenfoot.Actor |
---|
addedToWorld, getHeight, getImage, getIntersectingObjects, getNeighbours, getObjectsAtOffset, getObjectsInRange, getOneIntersectingObject, getOneObjectAtOffset, getRotation, getWidth, 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(Ship ship)
Method Detail |
---|
public void act()
act
in class greenfoot.Actor
public final boolean atShip()
public boolean atWater()
public boolean atWorldEdge()
public final boolean carryingTomato()
protected final void dropTomato()
public abstract java.lang.String getCurrentImage()
public final void loadTomato()
public void move()
protected boolean randomChance(int percent)
public final boolean removeTomato()
public boolean seePaint(java.lang.String color)
public void spit(java.lang.String color)
public void turn(int angle)
public void turnHome()