frog.demo
Class DemoController

java.lang.Object
  extended by frog.demo.DemoController

public class DemoController
extends Object

The DemoController manages all Sprites and sound in the game. After the initial DemoGame window has been set up, it uses DemoController to run the game. After DemoController has been created, DemoGame's only job will be to ensure that the requested FPS is maintained and that special keyboard events are handled (such as mute).

Author:
Team Better Recognize

Field Summary
static int CIRCLE
          Shape recognized in this game.
(package private)  boolean enableSound
          Determines if sound should be enabled or not.
static int SQUARE
          Shape recognized in this game.
static int TRIANGLE
          Shape recognized in this game.
static int X
          Shape recognized in this game.
static int Z
          Shape recognized in this game.
 
Constructor Summary
DemoController(DemoGame game)
          Creates a new DemoController for the instance of DemoGame.
 
Method Summary
 void draw(Graphics g)
          Calls the draw method on all sprites after painting the background.
 void killUFO(int type, int player)
          Creates a new KillEvent for a given player on a given UFO.
protected  void notifyAbduction(CowSprite cow)
          Allows the controller to put the abducted cow to a special queue.
protected  void notifyDeadUFO()
          A UFO has finished exploding and needs to be removed from the ufoDeath queue.
protected  void notifyRelease(CowSprite cow)
          Notifies the controller of the release of a cow from the hold of a UFO.
protected  void removeCow(CowSprite cow)
          Completely removes the given CowSprite from the game.
protected  void removeUFO(UFOSprite ufo)
          Removes a UFO from the game and decrements the total UFO count by 1.
 void update()
          Calls the update method of each Sprite which should in turn move one step across the screen.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CIRCLE

public static final int CIRCLE
Shape recognized in this game.

See Also:
Constant Field Values

SQUARE

public static final int SQUARE
Shape recognized in this game.

See Also:
Constant Field Values

TRIANGLE

public static final int TRIANGLE
Shape recognized in this game.

See Also:
Constant Field Values

X

public static final int X
Shape recognized in this game.

See Also:
Constant Field Values

Z

public static final int Z
Shape recognized in this game.

See Also:
Constant Field Values

enableSound

boolean enableSound
Determines if sound should be enabled or not.

Constructor Detail

DemoController

public DemoController(DemoGame game)
Creates a new DemoController for the instance of DemoGame.

Parameters:
game - the reference to the DemoGame that this controller is a part of
Method Detail

draw

public final void draw(Graphics g)
Calls the draw method on all sprites after painting the background.

Parameters:
g - the Graphics context to draw to.

killUFO

public void killUFO(int type,
                    int player)
Creates a new KillEvent for a given player on a given UFO. A KillEvent will be executed on the next update and if a matching UFO is found to the type given, it will be deleted and points awarded to that player.

Parameters:
type - the type of UFO to destroy. Could be CIRCLE, TRIANGLE, etc.
player - the Player to give the kill points to.

notifyAbduction

protected void notifyAbduction(CowSprite cow)
Allows the controller to put the abducted cow to a special queue. A cow on that queue will not be handed out as a target to the other UFOs. All of that cow's abductors will be given new cows to chase after.

Parameters:
cow - the CowSprite that needs to be modified.

notifyDeadUFO

protected void notifyDeadUFO()
A UFO has finished exploding and needs to be removed from the ufoDeath queue.


notifyRelease

protected void notifyRelease(CowSprite cow)
Notifies the controller of the release of a cow from the hold of a UFO. A released cow will be moved back to the available list of cows and all UFOs are assigned new targets.

Parameters:
cow - the CowSprite that was released.

removeCow

protected void removeCow(CowSprite cow)
Completely removes the given CowSprite from the game. This is when a UFO has disappeared off-screen with a cow in its hold.

Parameters:
cow - the CowSprite to remove from the game.

removeUFO

protected void removeUFO(UFOSprite ufo)
Removes a UFO from the game and decrements the total UFO count by 1.

Parameters:
ufo - the UFOSprite to destroy.

update

public final void update()
Calls the update method of each Sprite which should in turn move one step across the screen. Every update checks for game over condition and occasionally makes the cows "moo".