Andreas Garmannslund / Mbed 2 deprecated SimplePlatformGame

Dependencies:   N5110 PinDetect PowerControl mbed

Embed: (wiki syntax)

« Back to documentation index

StateManager Class Reference

StateManager Class Reference

Finite State Machine for program flow. More...

#include <StateManager.h>

Public Member Functions

 StateManager (N5110 *lcd, InputManager *input, Sound *sound, MainState firstState)
 Creates a new finite state machine.
 ~StateManager ()
 Frees allocated memory.
void update (float dt)
 Update logic of the current state.
void render ()
 Draw the current state to the lcd.
void requestStateChange (MainState newState)
 Can be used to request the fsm to switch state.
void processRequest ()
 Sees if any requests to change the state have been made.

Detailed Description

Finite State Machine for program flow.

Definition at line 17 of file StateManager.h.


Constructor & Destructor Documentation

StateManager ( N5110 *  lcd,
InputManager input,
Sound sound,
MainState  firstState 
)

Creates a new finite state machine.

The states are defined in State.h

Parameters:
lcdPointer to the lcd
inputPointer to the InputManager which is controlling user input.
firstStateThe initial state of the finite state machine.

Definition at line 25 of file StateManager.h.

~StateManager (  )

Frees allocated memory.

Definition at line 29 of file StateManager.h.


Member Function Documentation

void processRequest (  )

Sees if any requests to change the state have been made.

Definition at line 56 of file StateManger.cpp.

void render (  )

Draw the current state to the lcd.

Definition at line 51 of file StateManger.cpp.

void requestStateChange ( MainState  newState )

Can be used to request the fsm to switch state.

Parameters:
newStateThe requested state

Definition at line 38 of file StateManger.cpp.

void update ( float  dt )

Update logic of the current state.

Definition at line 46 of file StateManger.cpp.