Files
PWrProjSO2v2/so2-game/Stopwatch.cpp
T
2020-05-04 15:56:02 +02:00

41 lines
555 B
C++

#include "Stopwatch.h"
Stopwatch::Stopwatch()
{
//ctor
// Jan Potocki 2018
}
void Stopwatch::start()
{
running = true;
miliseconds = 0;
measureThread = std::thread(&Stopwatch::measure, this);
}
void Stopwatch::stop()
{
running = false;
measureThread.join();
}
bool Stopwatch::isRunning()
{
return running;
}
float Stopwatch::read()
{
float measurement = (float)miliseconds / 1000;
return measurement;
}
void Stopwatch::measure()
{
while(running)
{
usleep(1000);
miliseconds++;
}
}