]> git.localhorst.tv Git - l2e.git/blob - src/app/State.h
added timer facility
[l2e.git] / src / app / State.h
1 /*
2  * State.h
3  *
4  *  Created on: Apr 8, 2012
5  *      Author: holy
6  */
7
8 #ifndef APP_APPLICATIONSTATE_H_
9 #define APP_APPLICATIONSTATE_H_
10
11 #include "Timer.h"
12
13 #include <SDL.h>
14
15 namespace app {
16
17 class Application;
18 class Input;
19
20 class State {
21
22 public:
23         virtual ~State() { };
24
25 public:
26         /// do some setup
27         /// called when the state first enters the stack
28         /// @param ctrl the Application running the state
29         virtual void EnterState(Application &ctrl, SDL_Surface *screen) = 0;
30         /// do some cleanup
31         /// called when the state is popped from the stack
32         virtual void ExitState(Application &ctrl, SDL_Surface *screen) = 0;
33         /// called when the state becomes the active one
34         virtual void ResumeState(Application &ctrl, SDL_Surface *screen) = 0;
35         /// called when the state becomes inactive
36         virtual void PauseState(Application &ctrl, SDL_Surface *screen) = 0;
37
38         /// adapt the state's graphics to given dimensions
39         virtual void Resize(int width, int height) = 0;
40
41         virtual void HandleInput(const Input &) = 0;
42         virtual void UpdateWorld(float deltaT) = 0;
43         virtual void Render(SDL_Surface *) = 0;
44
45 public:
46         Timers<Uint32> &GraphicsTimers() { return graphicsTimers; }
47         Timers<float> &PhysicsTimers() { return physicsTimers; }
48
49 private:
50         Timers<Uint32> graphicsTimers;
51         Timers<float> physicsTimers;
52
53 };
54
55 }
56
57 #endif /* APP_STATE_H_ */