spacebox/src/Timer.hpp

45 lines
978 B
C++

/* +------------------------------------------------------+
____/ \____ /| - Open source game framework licensed to freely use, |
\ / / | copy, modify and sell without restriction |
+--\ ^__^ /--+ | |
| ~/ \~ | | - created for <https://foam.shampoo.ooo> |
| ~~~~~~~~~~~~ | +------------------------------------------------------+
| SPACE ~~~~~ | /
| ~~~~~~~ BOX |/
+-------------*/
#pragma once
#include "SDL.h"
class Timer
{
public:
enum State : bool
{
OFF,
ON
};
private:
bool timing = Timer::ON;
int ticks = 0, ticks_previous = 0, frame_duration = 0, ticks_elapsed = 0;
public:
Timer();
bool state();
void toggle();
void toggle(bool);
void reset();
float ms_elapsed();
float seconds_elapsed();
float ms_last_frame();
float seconds_last_frame();
void update();
};