Pacman Torben Petré
Loading...
Searching...
No Matches
Stopwatch.h
Go to the documentation of this file.
1#ifndef STOPWATCH_H
2#define STOPWATCH_H
3
4#include <chrono>
5
6
7namespace logic {
8
9 class Stopwatch {
10 public:
14 Stopwatch(Stopwatch &other) = delete;
15 void operator=(const Stopwatch &) = delete;
16
21 [[nodiscard]] static Stopwatch& getInstance();
22
23
28 [[nodiscard]] double getDeltaTime() const;
29
34 void tick();
35
39 void reset();
40
41 private:
42 Stopwatch();
43
44 std::chrono::time_point<std::chrono::high_resolution_clock> lastTime;
45 double deltaTime = 0.0;
46 };
47}
48
49
50#endif //STOPWATCH_H
void operator=(const Stopwatch &)=delete
void reset()
Resets the Stopwatch.
Definition Stopwatch.cpp:27
void tick()
Updates deltatime to hold the time difference between now and the last tick.
Definition Stopwatch.cpp:21
static Stopwatch & getInstance()
Returns an instance of the Stopwatch class.
Definition Stopwatch.cpp:11
Stopwatch(Stopwatch &other)=delete
double getDeltaTime() const
Returns the deltatime, updated by Stopwatch::tick.
Definition Stopwatch.cpp:16
Definition Difficulty.h:6