|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectfrog.demo.UFOSprite
public class UFOSprite
Represents a single UFO in the DemoGame. A UFOSprite is responsible for a
UFO's behavior which includes swooping in from the top of the screen, moving
towards a CowSprite. If it abducts a CowSprite, it heads back to the top of
the screen and disappears.
UFOSprites are responsible for keeping track of a UFO's sounds, images, and
states. UFOSprites come in five different types: circle, triangle, square,
X, and Z. UFOSprites can be destroyed by a Player making a matching gesture
and will reward that Player with 100 points.
| Field Summary | |
|---|---|
static int |
ABDUCTION_TIME
The amount of time it takes for a cow to be abducted given HOVER_HEIGHT and CowSprite.ABDUCT_SPEED. |
static int |
EXPLODING_TIME
Frames for UFO exploding |
static float |
HOVER_HEIGHT
Height at which the UFO will hover over a cow target |
static float |
SPEEDX
UFO movement speed |
static float |
SPEEDY
UFO movement speed |
int |
type
Type of gesture shown on this UFO |
static int |
UFO_SCORE
Points killing a UFO is worth |
| Constructor Summary | |
|---|---|
UFOSprite(DemoGame game,
int type)
Constructs a new UFOSprite. |
|
| Method Summary | |
|---|---|
void |
draw(Graphics g)
Draws this sprite to the given Graphics context. |
boolean |
equals(Object other)
|
void |
giveTarget(CowSprite cow)
Gives a new target CowSprite for the UFO to approach. |
int |
kill()
Disables this sprite's draw method. |
void |
setKillColor(Color color)
|
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 int UFO_SCORE
public static final float SPEEDX
public static final float SPEEDY
public static final float HOVER_HEIGHT
public static final int ABDUCTION_TIME
CowSprite.ABDUCT_SPEED.
public static final int EXPLODING_TIME
public final int type
| Constructor Detail |
|---|
public UFOSprite(DemoGame game,
int type)
game - the DemoGame this UFOSprite is a part of.type - the gesture type of this UFO.| Method Detail |
|---|
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 void giveTarget(CowSprite cow)
cow - a CowSprite to chase after.public int kill()
Sprite
kill in interface Spritepublic void setKillColor(Color color)
public void update()
Sprite
update in interface Sprite
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||