4 * Created on: Apr 8, 2012
8 #ifndef APP_APPLICATIONSTATE_H_
9 #define APP_APPLICATIONSTATE_H_
18 /// Application state base class for use with app::Application.
25 /// Called by Application when pushing this state.
26 void EnterState(Application &ctrl, SDL_Surface *screen);
27 /// Called by Application when popping this state.
28 void ExitState(Application &ctrl, SDL_Surface *screen);
29 /// Called by Application when this state becomes the top state.
30 void ResumeState(Application &ctrl, SDL_Surface *screen);
31 /// Called by Application when this state no longer is the top state.
32 void PauseState(Application &ctrl, SDL_Surface *screen);
34 /// Called by Application on SDL window resize events.
35 void Resize(int width, int height);
37 /// Handle interactive events such as input and timers.
38 virtual void HandleEvents(const Input &) = 0;
39 /// Update the time-dependant world representation.
40 virtual void UpdateWorld(float deltaT) = 0;
41 /// Draw a picture of the world.
42 virtual void Render(SDL_Surface *) = 0;
45 /// Do some setup that needs an application and/or screen handle and thus
46 /// can not be done by the constructor.
47 /// Called when the state first enters the stack.
48 /// @param ctrl the Application running the state
49 virtual void OnEnterState(Application &ctrl, SDL_Surface *screen) = 0;
51 /// Called when the state is popped from the stack.
52 virtual void OnExitState(Application &ctrl, SDL_Surface *screen) = 0;
53 /// Called when the state becomes the active one.
54 virtual void OnResumeState(Application &ctrl, SDL_Surface *screen) = 0;
55 /// Called when the state becomes inactive.
56 virtual void OnPauseState(Application &ctrl, SDL_Surface *screen) = 0;
58 /// Adapt the state's graphics to given dimensions.
59 /// NOTE: currently, this is only called for the stack top and not
60 /// propagated on stack changes.
61 /// Will be fixed soom ;).
62 virtual void OnResize(int width, int height) = 0;
65 /// Timers handle intended for graphics, sync'ed with render time.
66 /// These timers are only updated for the stack top and thus appear paused
67 /// when the state is visible (roughly).
68 Timers<Uint32> &GraphicsTimers() { return graphicsTimers; }
69 /// Timers handle intended for graphics, sync'ed with world time.
70 /// These timers are only updated for the stack top and thus appear paused
71 /// when the state is visible (roughly).
72 Timers<float> &PhysicsTimers() { return physicsTimers; }
75 Timers<Uint32> graphicsTimers;
76 Timers<float> physicsTimers;
82 #endif /* APP_STATE_H_ */