-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathTimer.h
64 lines (56 loc) · 858 Bytes
/
Timer.h
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
62
63
64
#ifndef _TIMERS_H
#define _TIMERS_H
#include "imgui.h"
class Timer
{
float second_passed;
float second_start;
float reset_point;
//timer flag;
bool flag_active;
void calculate_time()
{
if(second_passed==second_start)
{
second_start=ImGui::GetTime();second_passed+=0.00000001;
}
else
{
second_passed=ImGui::GetTime()-second_start;
}
}
public:
Timer()
{
second_passed=0.0;
reset_point=0.0;
second_start=0.0;
flag_active=false;
}
void startTimer()
{
flag_active=true;
calculate_time();
}
void reset()
{
second_passed=0.0;
second_start=reset_point;
flag_active=false;
}
bool isActive()
{
return flag_active;
}
float getTicks()
{
if(flag_active)
{
calculate_time();
return second_passed;
}
else
return 0.0f;
}
};
#endif