Hugo Hu / Mbed 2 deprecated BRAVEHEART

Dependencies:   mbed N5110 ShiftReg PinDetect

StateManager.h

Committer:
Siriagus
Date:
2015-05-02
Revision:
8:9ac6a428fa26
Parent:
7:678873947b29
Child:
10:f2488a0ecab7

File content as of revision 8:9ac6a428fa26:

#ifndef STATE_MANAGER_H
#define STATE_MANAGER_H

#include "State.h"
#include "MainMenu.h"
#include "Game.h"
#include "TitleScreen.h"

// Main Finite State Machine - controls the flow between the main states
class StateManager
{
    public:
        StateManager(N5110 *lcd, InputManager* input, MainState firstState)
                    : lcd(lcd),  input(input){currentState = 0; nextState = NO_STATE; changeState(firstState);}
        ~StateManager() {if (currentState != 0) delete currentState;}
        
        void update(float dt);
        void render();
        
        void requestStateChange(MainState newState);
        
        void processRequest(); // See if any request to change the state have been made
        
    private:
        void changeState(MainState newState); // Deletes the current main state and creates a new one
    
    // Variables    
    private:
        N5110 *lcd;
        InputManager *input;
        State* currentState; // Current state object
        MainState nextState;
};

#endif