frog.demo
Class UFOSprite

java.lang.Object
  extended by frog.demo.UFOSprite
All Implemented Interfaces:
Sprite

public class UFOSprite
extends Object
implements Sprite

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.

Author:
Team Better Recognize

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

UFO_SCORE

public static final int UFO_SCORE
Points killing a UFO is worth

See Also:
Constant Field Values

SPEEDX

public static final float SPEEDX
UFO movement speed

See Also:
Constant Field Values

SPEEDY

public static final float SPEEDY
UFO movement speed

See Also:
Constant Field Values

HOVER_HEIGHT

public static final float HOVER_HEIGHT
Height at which the UFO will hover over a cow target

See Also:
Constant Field Values

ABDUCTION_TIME

public static final int ABDUCTION_TIME
The amount of time it takes for a cow to be abducted given HOVER_HEIGHT and CowSprite.ABDUCT_SPEED.

See Also:
Constant Field Values

EXPLODING_TIME

public static final int EXPLODING_TIME
Frames for UFO exploding

See Also:
Constant Field Values

type

public final int type
Type of gesture shown on this UFO

Constructor Detail

UFOSprite

public UFOSprite(DemoGame game,
                 int type)
Constructs a new UFOSprite.

Parameters:
game - the DemoGame this UFOSprite is a part of.
type - the gesture type of this UFO.
Method Detail

draw

public void draw(Graphics g)
Description copied from interface: Sprite
Draws this sprite to the given Graphics context.

Specified by:
draw in interface Sprite
Parameters:
g - the Graphics context this sprite should draw itself to.

equals

public boolean equals(Object other)
Overrides:
equals in class Object

giveTarget

public void giveTarget(CowSprite cow)
Gives a new target CowSprite for the UFO to approach.

Parameters:
cow - a CowSprite to chase after.

kill

public int kill()
Description copied from interface: Sprite
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.

Specified by:
kill in interface Sprite
Returns:
number of points this sprite is worth, if any.

setKillColor

public void setKillColor(Color color)

update

public void update()
Description copied from interface: Sprite
Causes this sprite update its current state. This may be moving by one step or adjusting it's current display picture.

Specified by:
update in interface Sprite