-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGameClock.cpp
More file actions
68 lines (57 loc) · 1.19 KB
/
Copy pathGameClock.cpp
File metadata and controls
68 lines (57 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/**
*
* @file GameClock.cpp
* @author Gaspard Kirira
*
* Copyright 2026, Gaspard Kirira.
* All rights reserved.
* https://github.com/vixcpp/game
*
* Use of this source code is governed by a MIT license
* that can be found in the LICENSE file.
*
* Vix.cpp
*
*/
#include <vix/game/GameClock.hpp>
namespace vix::game
{
void GameClock::start() noexcept
{
start_ = now();
started_ = true;
}
void GameClock::reset() noexcept
{
start_ = time_point{};
started_ = false;
}
bool GameClock::started() const noexcept
{
return started_;
}
GameClock::time_point GameClock::now() noexcept
{
return vix::time::SteadyClock::now_chrono();
}
vix::time::Timestamp GameClock::timestamp() noexcept
{
return vix::time::SystemClock::now();
}
vix::time::Duration GameClock::elapsed() const noexcept
{
if (!started_)
{
return vix::time::Duration{};
}
return since(start_);
}
vix::time::Duration GameClock::since(const time_point &point) noexcept
{
return vix::time::SteadyClock::since(point);
}
const GameClock::time_point &GameClock::start_time() const noexcept
{
return start_;
}
} // namespace vix::game