-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCFPS.cpp
More file actions
50 lines (37 loc) · 1.1 KB
/
CFPS.cpp
File metadata and controls
50 lines (37 loc) · 1.1 KB
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
//=============================================================================
#include "CFPS.h"
//=============================================================================
CFPS CFPS::FPSControl;
//=============================================================================
CFPS::CFPS()
{
OldTime = 0;
LastTime = 0;
SpeedFactor = 0;
Frames = 0;
NumFrames = 0;
}
//=============================================================================
void CFPS::OnLoop()
{
if(OldTime + 1000 < SDL_GetTicks())
{
OldTime = SDL_GetTicks();
NumFrames = Frames;
Frames = 0;
}
SpeedFactor = ((SDL_GetTicks() - LastTime) / 1000.0f) * 32.0f;
LastTime = SDL_GetTicks();
Frames++;
}
//=============================================================================
const int CFPS::GetFPS()
{
return NumFrames;
}
//------------------------------------------------------------------------------
const float CFPS::GetSpeedFactor()
{
return SpeedFactor;
}
//==============================================================================