nsnake
Classic snake game for the terminal
Toggle main menu visibility
Loading...
Searching...
No Matches
src
Misc
Timer.hpp
1
#ifndef TIMER_H_DEFINED
2
#define TIMER_H_DEFINED
3
4
#include <sys/time.h>
5
7
class
Timer
8
{
9
public
:
10
Timer();
11
14
void
start
();
15
17
void
pause
();
18
20
void
unpause
();
21
23
bool
isRunning
();
24
26
bool
isPaused
();
27
29
// @note If the timer's not started, will return 0.
30
suseconds_t
delta_us
();
31
33
suseconds_t
delta_ms
();
34
36
suseconds_t
delta_s
();
37
38
protected
:
39
suseconds_t startMark;
40
suseconds_t stopMark;
41
suseconds_t pausedMark;
42
43
bool
running;
44
bool
paused;
45
};
46
47
#endif
/* TIMER_H_DEFINED */
48
Timer::pause
void pause()
Temporarily stops the timer.
Definition
Timer.cpp:34
Timer::isRunning
bool isRunning()
Tells if the timer's still running (hasn't called stop()).
Definition
Timer.cpp:53
Timer::start
void start()
Sets a starting point for the timer.
Definition
Timer.cpp:26
Timer::delta_us
suseconds_t delta_us()
Returns the whole timer's difference in milisseconds.
Definition
Timer.cpp:61
Timer::unpause
void unpause()
Restarts the timer if it was paused.
Definition
Timer.cpp:43
Timer::delta_ms
suseconds_t delta_ms()
Returns the milisseconds part of the timer's difference.
Definition
Timer.cpp:75
Timer::delta_s
suseconds_t delta_s()
Returns the seconds part of the timer's difference.
Definition
Timer.cpp:79
Timer::isPaused
bool isPaused()
Tells if the timer's paused.
Definition
Timer.cpp:57
Generated on
for nsnake by
1.17.0