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 /// Do some setup that needs an application and/or screen handle and thus
26 /// can not be done by the constructor.
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;
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;
38 /// Adapt the state's graphics to given dimensions.
39 /// NOTE: currently, this is only called for the stack top and not
40 /// propagated on stack changes.
41 /// Will be fixed soom ;).
42 virtual void Resize(int width, int height) = 0;
44 /// Handle interactive events such as input and timers.
45 virtual void HandleEvents(const Input &) = 0;
46 /// Update the time-dependant world representation.
47 virtual void UpdateWorld(float deltaT) = 0;
48 /// Draw a picture of the world.
49 virtual void Render(SDL_Surface *) = 0;
52 /// Timers handle intended for graphics, sync'ed with render time.
53 /// These timers are only updated for the stack top and thus appear paused
54 /// when the state is visible (roughly).
55 Timers<Uint32> &GraphicsTimers() { return graphicsTimers; }
56 /// Timers handle intended for graphics, sync'ed with world time.
57 /// These timers are only updated for the stack top and thus appear paused
58 /// when the state is visible (roughly).
59 Timers<float> &PhysicsTimers() { return physicsTimers; }
62 Timers<Uint32> graphicsTimers;
63 Timers<float> physicsTimers;
69 #endif /* APP_STATE_H_ */