Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed N5110 ShiftReg PinDetect
StateManager.h@8:9ac6a428fa26, 2015-05-02 (annotated)
- Committer:
- Siriagus
- Date:
- Sat May 02 00:22:43 2015 +0000
- Revision:
- 8:9ac6a428fa26
- Parent:
- 7:678873947b29
- Child:
- 10:f2488a0ecab7
Added Splash/Title Screen + Prototyping player movement
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Siriagus | 4:d6661b976359 | 1 | #ifndef STATE_MANAGER_H |
Siriagus | 4:d6661b976359 | 2 | #define STATE_MANAGER_H |
Siriagus | 4:d6661b976359 | 3 | |
Siriagus | 4:d6661b976359 | 4 | #include "State.h" |
Siriagus | 5:100d960fc6d5 | 5 | #include "MainMenu.h" |
Siriagus | 7:678873947b29 | 6 | #include "Game.h" |
Siriagus | 8:9ac6a428fa26 | 7 | #include "TitleScreen.h" |
Siriagus | 4:d6661b976359 | 8 | |
Siriagus | 4:d6661b976359 | 9 | // Main Finite State Machine - controls the flow between the main states |
Siriagus | 4:d6661b976359 | 10 | class StateManager |
Siriagus | 4:d6661b976359 | 11 | { |
Siriagus | 4:d6661b976359 | 12 | public: |
Siriagus | 7:678873947b29 | 13 | StateManager(N5110 *lcd, InputManager* input, MainState firstState) |
Siriagus | 7:678873947b29 | 14 | : lcd(lcd), input(input){currentState = 0; nextState = NO_STATE; changeState(firstState);} |
Siriagus | 5:100d960fc6d5 | 15 | ~StateManager() {if (currentState != 0) delete currentState;} |
Siriagus | 4:d6661b976359 | 16 | |
Siriagus | 7:678873947b29 | 17 | void update(float dt); |
Siriagus | 4:d6661b976359 | 18 | void render(); |
Siriagus | 4:d6661b976359 | 19 | |
Siriagus | 7:678873947b29 | 20 | void requestStateChange(MainState newState); |
Siriagus | 7:678873947b29 | 21 | |
Siriagus | 7:678873947b29 | 22 | void processRequest(); // See if any request to change the state have been made |
Siriagus | 7:678873947b29 | 23 | |
Siriagus | 7:678873947b29 | 24 | private: |
Siriagus | 4:d6661b976359 | 25 | void changeState(MainState newState); // Deletes the current main state and creates a new one |
Siriagus | 7:678873947b29 | 26 | |
Siriagus | 7:678873947b29 | 27 | // Variables |
Siriagus | 4:d6661b976359 | 28 | private: |
Siriagus | 4:d6661b976359 | 29 | N5110 *lcd; |
Siriagus | 4:d6661b976359 | 30 | InputManager *input; |
Siriagus | 4:d6661b976359 | 31 | State* currentState; // Current state object |
Siriagus | 7:678873947b29 | 32 | MainState nextState; |
Siriagus | 4:d6661b976359 | 33 | }; |
Siriagus | 4:d6661b976359 | 34 | |
Siriagus | 5:100d960fc6d5 | 35 | #endif |