-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTimer.cpp
More file actions
49 lines (41 loc) · 925 Bytes
/
Timer.cpp
File metadata and controls
49 lines (41 loc) · 925 Bytes
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
/*
* Authors: Christine Seng, Erick Martinez, Georgia Rushing, Graham Balas, Nolan Schirripa
* Assignment Title: Group Project (Timer.cpp)
* Assignment Description: defines Timer class that can be used to set ticks and frame rate
* Due Date: 12/09/2024
* Date Created: 10/31/2024
* Date Last Modified: 12/07/2024
*/
#include "Timer.h"
Timer::Timer()
{
//Initialize the variables
mStartTicks = 0;
mStarted = false;
}
void Timer::start()
{
//Start the timer
mStarted = true;
//Get the current clock time
mStartTicks = SDL_GetTicks();
}
void Timer::stop()
{
//Stop the timer
mStarted = false;
//Reset Ticks
mStartTicks = 0;
}
int Timer::getTicks()
{
//The actual timer time
int time = 0;
//If the timer is running
if (mStarted)
{
//Return the current time minus the start time
time = SDL_GetTicks() - mStartTicks;
}
return time;
}