-
Notifications
You must be signed in to change notification settings - Fork 0
/
Timer.cpp
61 lines (60 loc) · 2.16 KB
/
Timer.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
//--------------------------------------------------------------------------------------------------------------------
/// @file Timer.h
/// @brief set the constructor, set and get methods
//--------------------------------------------------------------------------------------------------------------------
#include "Timer.h"
Timer::Timer()
{
m_startTime = SDL_GetTicks();
m_endTime = 0;
// for computers at uni devide by 1000
// for my personal pc devide by 2500
m_cameraTime = (m_startTime - m_endTime)/2500;
m_deltaTime = (m_startTime - m_endTime)/2500;
m_pause = false;
m_slowMotion = m_cameraTime/4;
}
//--------------------------------------------------------------------------------------------------------------------
float Timer::CameraTime() const
{
return m_cameraTime;
}
//--------------------------------------------------------------------------------------------------------------------
float Timer::DeltaTime() const
{
return m_deltaTime;
}
//--------------------------------------------------------------------------------------------------------------------
float Timer::getSlowMow() const
{
return m_slowMotion;
}
//--------------------------------------------------------------------------------------------------------------------
bool Timer::getPause() const
{
return m_pause;
}
//--------------------------------------------------------------------------------------------------------------------
void Timer::setDeltaTime(float _deltaTime)
{
m_deltaTime = _deltaTime;
}
//--------------------------------------------------------------------------------------------------------------------
void Timer::setEndTime(float _endTime)
{
m_endTime = _endTime;
}
//--------------------------------------------------------------------------------------------------------------------
void Timer::pauseTimer()
{
// sets the pause button back to true;
m_pause = true;
setDeltaTime(0);
}
//--------------------------------------------------------------------------------------------------------------------
void Timer::unPauseTimer()
{
// sets the pause button back to false
m_pause = false;
setDeltaTime(CameraTime());
}