CowSprite Class Reference
Represents a single cow on the screen. More...
Public Member Functions | |
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. | |
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. | |
int | kill () |
Disables this sprite's draw method. | |
void | update () |
Causes this sprite update its current state. | |
Public Attributes | |
final HashSet< UFOSprite > | chasers = new HashSet<UFOSprite>() |
UFOs currently chasing this cow. | |
Static Public Attributes | |
static final float | SPEED = 0.0005f |
Cow movement speed. | |
static final float | ABDUCT_SPEED = 0.001f |
static final float | FALL_SPEED = 0.01f |
static final float | GROUND_Y = .8f |
Cow walking Y-position. | |
static final int | WALKING = 0 |
Status type. | |
static final int | BEING_ABDUCTED = 1 |
static final int | ABDUCTED = 2 |
static final int | LEFT = 0 |
Direction type. | |
static final int | RIGHT = 1 |
static final int | STAND = 2 |
Package Functions | |
CowSprite (DemoGame game) | |
Creates a new CowSprite with a reference to the DemoGame that it is running within. |
Detailed Description
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.
Constructor & Destructor Documentation
Member Function Documentation
void addChasingUFO | ( | UFOSprite | ufo | ) |
Adds an additional UFO to the list of chasing UFOs.
Chasing UFOs have targeted this cow for abduction. If this cow is abducted by a UFO, all UFOSprites are notified.
- Parameters:
-
ufo a UFO that is now chasing this cow.
void draw | ( | Graphics | g | ) |
Draws this sprite to the given Graphics context.
- Parameters:
-
g the Graphics context this sprite should draw itself to.
Implements Sprite.
boolean equals | ( | Object | other | ) |
int getState | ( | ) |
Returns the current state of this cow.
Possible values include:
- WALKING
- BEING_ABDUCTED
- ABDUCTED
- Returns:
- the current status of this cow.
float getX | ( | ) |
Returns the current X position of this cow.
- Returns:
- the current X position of this cow.
float getY | ( | ) |
Returns the current Y position of this cow.
- Returns:
- the current Y position of this cow.
int kill | ( | ) |
Disables this sprite's draw method.
Performs any necessary clean up and displays any effects that need to appear upon this object's death. Some sprites may be worth points when they are killed. If this is the case, kill will return those points as an integer.
- Returns:
- number of points this sprite is worth, if any.
Implements Sprite.
void setState | ( | int | state | ) |
Sets the state of this cow to a new one.
Valid values are:
- WALKING
- BEING_ABDUCTED
- ABDUCTED
- Parameters:
-
state the state to set this cow to.
void setX | ( | float | x | ) |
Sets the current X position of this cow.
- Parameters:
-
x a new X position for this cow.
void setY | ( | float | y | ) |
Sets the current Y position of this cow.
- Parameters:
-
y a new Y position for this cow.
void update | ( | ) |
Causes this sprite update its current state.
This may be moving by one step or adjusting it's current display picture.
Implements Sprite.
Member Data Documentation
final float ABDUCT_SPEED = 0.001f [static] |
final int ABDUCTED = 2 [static] |
final int BEING_ABDUCTED = 1 [static] |
final float FALL_SPEED = 0.01f [static] |
final float GROUND_Y = .8f [static] |
Cow walking Y-position.
final int LEFT = 0 [static] |
Direction type.
final int RIGHT = 1 [static] |
final float SPEED = 0.0005f [static] |
Cow movement speed.
final int STAND = 2 [static] |
final int WALKING = 0 [static] |
Status type.
The documentation for this class was generated from the following file:
- /Users/dev/Documents/SVN brazos.cs.tcu.edu/trunk/FROG/src/frog/demo/CowSprite.java