-
Notifications
You must be signed in to change notification settings - Fork 0
/
FrameTimer.cpp
executable file
·58 lines (46 loc) · 1.02 KB
/
FrameTimer.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
#include "FrameTimer.h"
#include <iostream>
FrameTimer::FrameTimer()
:
begTime( 0 ),
interval( 0 ),
frame( 0 )
{}
FrameTimer::~FrameTimer()
{}
void FrameTimer::start( int startFrame, int endFrame, unsigned long interval )
{
if( !isRunning() )
{
this->begTime = (unsigned long) clock();
this->interval = interval;
this->startFrame = startFrame;
this->endFrame = endFrame;
this->frame = startFrame;
this->frameInterval = interval / ( endFrame - startFrame );
std::cout << frame<<'\n';
}
}
void FrameTimer::reset()
{}
void FrameTimer::setInterval( unsigned long interval )
{
this->interval = interval;
this->frameInterval = interval / ( endFrame - startFrame );
}
bool FrameTimer::isRunning()
{
return this->running;
}
int FrameTimer::getFrame()
{
if( (unsigned long) clock() - this->begTime >= this->interval )
{
this->frame = this->startFrame;
}
if( (unsigned long) clock() - this->begTime >= this->frameInterval )
{
frame++;
}
return this->frame;
}