mako5.ctrl
Class GameStateMachine

java.lang.Object
  extended by mako5.ctrl.GameStateMachine

public class GameStateMachine
extends Object

Controls a group of game states and is capable of running them.

Version:
28-Sept 2005, 12-Apr 2006
Author:
Paul Jarrett

Constructor Summary
GameStateMachine()
          Creates a new GameStateMachine.
 
Method Summary
 void add(GameState s)
          Adds a new state.
 void cleanup()
          Cleans up after the program has finished.
 void exit()
          Terminates the program.
 GameState getCurrent()
          Returns the current game state.
 HashMap getData()
          Returns the stored game data for this.
 void loadResources()
           
 void loadStates()
           
 void run()
          Runs the program.
 void setCurrent(int i)
          Sets the current state.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GameStateMachine

public GameStateMachine()
Creates a new GameStateMachine.

Since:
23-May 2006
Method Detail

add

public void add(GameState s)
Adds a new state.

Parameters:
s - the state to add
Since:
23-May 2006

getCurrent

public GameState getCurrent()
Returns the current game state.

Returns:
the current game state, or null if none has been assigned.
Since:
23-May 2006

setCurrent

public void setCurrent(int i)
Sets the current state.

Parameters:
i - the index of the game state to switch to
Since:
28-Sept 2005, 12-Apr 2006

getData

public HashMap getData()
Returns the stored game data for this.

Returns:
a hashmap of stored game data
Since:
16-Jul 2006

exit

public void exit()
Terminates the program.

Since:
28-Sept 2005, 12-Apr 2006

cleanup

public void cleanup()
Cleans up after the program has finished. Gets rid of the display, and mouse and keyboard input devices.

Since:
16-Jul 2006

loadStates

public void loadStates()

loadResources

public void loadResources()

run

public void run()
Runs the program. This is how it does it: