|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectfrog.demo.CowSprite
public class CowSprite
Represents a single cow on the screen. CowSprites control the individual behavior of a cow which is to walk randomly about the bottom of the screen until a UFO begins to abduct the cow. CowSprite handles the animation and status of a cow as well as its position and image.
| Field Summary | |
|---|---|
static float |
ABDUCT_SPEED
Cow movement speed. |
static int |
ABDUCTED
Status type. |
static int |
BEING_ABDUCTED
Status type. |
HashSet<UFOSprite> |
chasers
UFOs currently chasing this cow |
static float |
FALL_SPEED
Cow movement speed. |
static float |
GROUND_Y
Cow walking Y-position |
static int |
LEFT
Direction type. |
static int |
RIGHT
Direction type. |
static float |
SPEED
Cow movement speed. |
static int |
STAND
Direction type. |
static int |
WALKING
Status type. |
| Constructor Summary | |
|---|---|
CowSprite(DemoGame game)
Creates a new CowSprite with a reference to the DemoGame that it is running within. |
|
| Method Summary | |
|---|---|
void |
addChasingUFO(UFOSprite ufo)
Adds an additional UFO to the list of chasing UFOs. |
void |
draw(Graphics g)
Draws this sprite to the given Graphics context. |
boolean |
equals(Object other)
|
int |
getState()
Returns the current state of this cow. |
float |
getX()
Returns the current X position of this cow. |
float |
getY()
Returns the current Y position of this cow. |
int |
kill()
Disables this sprite's draw method. |
void |
setState(int state)
Sets the state of this cow to a new one. |
void |
setX(float x)
Sets the current X position of this cow. |
void |
setY(float y)
Sets the current Y position of this cow. |
void |
update()
Causes this sprite update its current state. |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final float SPEED
public static final float ABDUCT_SPEED
public static final float FALL_SPEED
public static final float GROUND_Y
public static final int WALKING
public static final int BEING_ABDUCTED
public static final int ABDUCTED
public static final int LEFT
public static final int RIGHT
public static final int STAND
public final HashSet<UFOSprite> chasers
| Constructor Detail |
|---|
CowSprite(DemoGame game)
game - the DemoGame that this CowSprite appears in.| Method Detail |
|---|
public void addChasingUFO(UFOSprite ufo)
ufo - a UFO that is now chasing this cow.public void draw(Graphics g)
Sprite
draw in interface Spriteg - the Graphics context this sprite should draw itself to.public boolean equals(Object other)
equals in class Objectpublic int getState()
public float getX()
public float getY()
public void setState(int state)
state - the state to set this cow to.public void setX(float x)
x - a new X position for this cow.public void setY(float y)
y - a new Y position for this cow.public int kill()
Sprite
kill in interface Spritepublic void update()
Sprite
update in interface Sprite
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||