]> git.localhorst.tv Git - sdl-test8.git/blob - src/app/Timer.h
some comments
[sdl-test8.git] / src / app / Timer.h
1 /*
2  * Timer.h
3  *
4  *  Created on: Apr 25, 2012
5  *      Author: holy
6  */
7
8 #ifndef APP_TIMER_H_
9 #define APP_TIMER_H_
10
11 namespace app {
12
13 /// Objects of class keep track of the current delta and the time elapsed since
14 /// their respective incarnation (which may also be tampered with).
15 /// It's also possible to scale the time e.g. for slow-motion or fast-forwarding.
16 class Timer {
17
18         public:
19                 explicit Timer(double scale = 1.0, double initialTime = 0.0)
20                                 : scale(scale), elapsed(initialTime), delta(0.0) { };
21
22         public:
23                 void Update(double dt);
24
25         public:
26                 double DeltaT(void) const { return delta; };
27                 double Elapsed(void) const;
28
29         private:
30                 double scale, elapsed, delta;
31
32 };
33
34 }
35
36 #endif /* APP_TIMER_H_ */