public abstract class Creature
extends greenfoot.Actor
| Constructor and Description |
|---|
Creature(Spaceship ship)
Create a creature at its ship.
|
| Modifier and Type | Method and Description |
|---|---|
void |
act()
Act - must be called as part of subclass act.
|
protected abstract void |
behave()
Defines what a `Creature` will do
|
java.lang.Boolean |
canMove() |
protected void |
dropTomato()
Drop the tomato we are carrying.
|
abstract java.lang.String |
getCurrentImage() |
int |
getMemory()
Retrieve a previously stored value.
|
int |
getNextXCoordinate() |
int |
getNextYCoordinate() |
Spaceship |
getShip() |
TomatoPile |
getSurroundingTomatoPile() |
boolean |
isAtShip() |
boolean |
isAtTomatoes() |
boolean |
isAtWater() |
boolean |
isAtWorldEdge() |
boolean |
isCarryingTomato()
Check whether we are carrying a tomato.
|
boolean |
isFlaggedForState(int state)
Retrieve the value of a flag.
|
boolean |
isSeeingPaint(java.lang.String color)
Check whether we can see paint of a given color where we are sitting.
|
void |
loadTomato()
Load a tomato onto *another* creature.
|
void |
move()
Move forward roughly in the current direction.
|
void |
move(int amount)
To avoid confusion/cheating, calling the built-in Greenfoot
move(int amount) does the same as the Creature move() function.
|
boolean |
removeTomato()
Remove the tomato currently carried (and return true).
|
void |
setFlag(int flagNo,
boolean val)
Store a user defined boolean value (a "flag").
|
void |
setImage(java.lang.String imageName) |
void |
setMemory(int val)
Store a user defined value.
|
void |
spit(java.lang.String color)
Spit a drop of paint onto the ground.
|
void |
turnAwayFrom(greenfoot.Actor actor) |
void |
turnAwayFrom(greenfoot.Actor actor,
int likelihoodOfExecutingTurn) |
void |
turnOppositeDirection(int angle) |
void |
turnTowards(greenfoot.Actor actor)
Turn in the direction of the specified `actor`
|
void |
turnTowards(greenfoot.Actor actor,
float likelihoodOfTurn) |
void |
turnTowardsHome()
turn towards the ship
|
void |
turnTowardsHome(float likelihoodOfTurn)
turn towards the ship with some likelihood
|
addedToWorld, getImage, getIntersectingObjects, getNeighbours, getObjectsAtOffset, getObjectsInRange, getOneIntersectingObject, getOneObjectAtOffset, getRotation, getWorld, getWorldOfType, getX, getY, intersects, isAtEdge, isTouching, removeTouching, setImage, setLocation, setRotation, turn, turnTowardspublic Creature(Spaceship ship)
public abstract java.lang.String getCurrentImage()
protected abstract void behave()
public final void setImage(java.lang.String imageName)
setImage in class greenfoot.ActorimageName - path of image to set this `Creature` instance topublic final void act()
act in class greenfoot.Actorpublic final void move(int amount)
move in class greenfoot.Actorpublic void turnTowards(greenfoot.Actor actor)
actor - - Actor to turn towardspublic void turnTowards(greenfoot.Actor actor,
float likelihoodOfTurn)
actor - the actor to turn towardslikelihoodOfTurn - the likelihood of successfully turning toward the specified actorpublic void turnTowardsHome()
public void turnTowardsHome(float likelihoodOfTurn)
likelihoodOfTurn - the likelihood of successfully turning toward the shippublic void turnOppositeDirection(int angle)
angle - the angle to turn away frompublic void turnAwayFrom(greenfoot.Actor actor)
actor - the actor to turn away frompublic void turnAwayFrom(greenfoot.Actor actor,
int likelihoodOfExecutingTurn)
actor - the actor to turn away fromlikelihoodOfExecutingTurn - the likelihood of executing the turnpublic final boolean isAtShip()
public final boolean isAtTomatoes()
public TomatoPile getSurroundingTomatoPile()
public final boolean isAtWater()
public boolean isAtWorldEdge()
public boolean isSeeingPaint(java.lang.String color)
public boolean isFlaggedForState(int state)
public final boolean isCarryingTomato()
public final boolean removeTomato()
protected final void dropTomato()
public final void loadTomato()
public void spit(java.lang.String color)
public void setMemory(int val)
public int getMemory()
public void setFlag(int flagNo,
boolean val)
public Spaceship getShip()
public void move()
public java.lang.Boolean canMove()
public int getNextXCoordinate()
public int getNextYCoordinate()