Masz tu kod mojego timera. Żeby nie powiedzieli że gotowce, to ci go w ogóle nie opiszę, i sam go rozpracujesz:
.cpp
ClockTimer::ClockTimer()
{
restart();
}
ClockTimer::~ClockTimer()
{
}
void ClockTimer::restart()
{
tick = 0;
timer2 = clock();
}
float ClockTimer::getTimeAsSeconds()
{
timer = clock();
return (timer - timer2) / 1000;
}
float ClockTimer::getTimeAsMiliseconds()
{
timer = clock();
return timer - timer2;
}
.h
#pragma once
#include <ctime>
class ClockTimer
{
float timer = 0;
float timer2 = 0;
unsigned int id = 0;
unsigned short int tick = 0; //to zignoruj
public:
ClockTimer();
~ClockTimer();
void restart();
float getTimeAsSeconds();
float getTimeAsMiliseconds();
};