GameKit  0.0.1a
C++ gamedev tools
Timer.cpp
Go to the documentation of this file.
1 /*
2  * =====================================================================================
3  *
4  * Filename: Timer.cpp
5  *
6  * Description:
7  *
8  * Created: 15/09/2014 19:31:35
9  *
10  * Author: Quentin Bazin, <gnidmoo@gmail.com>
11  *
12  * =====================================================================================
13  */
14 #include "gk/core/Timer.hpp"
15 #include "gk/core/GameClock.hpp"
16 
17 namespace gk {
18 
19 Timer::Timer(bool useRealTime) {
20  m_useRealTime = useRealTime;
22 }
23 
24 void Timer::stop() {
25  if(m_isStarted) {
26  m_isStarted = false;
28  }
29 }
30 
31 void Timer::start() {
32  if(!m_isStarted) {
33  m_isStarted = true;
35  }
36 }
37 
38 void Timer::reset() {
39  m_isStarted = false;
41  m_tick = 0;
42 }
43 
44 u32 Timer::time() const {
45  if(m_isStarted) {
47  } else {
48  return m_tick;
49  }
50 }
51 
53  if(m_isStarted) {
55  } else {
56  m_tick = time;
57  }
58 }
59 
60 } // namespace gk
61 
void start()
Start the timer.
Definition: Timer.cpp:31
void setTime(u32 time)
Set time.
Definition: Timer.cpp:52
void stop()
Stop the timer.
Definition: Timer.cpp:24
u32 m_t
Definition: Timer.hpp:85
void reset()
Reset the timer.
Definition: Timer.cpp:38
unsigned int u32
Definition: IntTypes.hpp:23
bool m_useRealTime
The timer will use system time instead of simulated time if set to true.
Definition: Timer.hpp:81
bool m_isStarted
Is true if the timer is running.
Definition: Timer.hpp:83
u32 time() const
Get time.
Definition: Timer.cpp:44
Timer(bool useRealTime=false)
Constructor.
Definition: Timer.cpp:19
static u32 getTicks(bool realTime=false)
Definition: GameClock.cpp:21
u32 m_tick
Definition: Timer.hpp:86