Engine²
Open-source game engine written in C++.
Loading...
Searching...
No Matches
FixedTimeUpdate.hpp
Go to the documentation of this file.
1#pragma once
2
4#include <chrono>
5#include <entt/entt.hpp>
6
7namespace Engine::Scheduler {
16 private:
19 inline static constexpr float DEFAULT_TICK_RATE = 1.0f / 50.0f;
20
21 public:
32 FixedTimeUpdate(Core &core, float tickRate = DEFAULT_TICK_RATE) : AScheduler(core), _tickRate(tickRate) {}
33
35 void RunSystems() override;
36
41 inline float GetTickRate() const { return _tickRate; }
42
49 inline void SetTickRate(float tickRate) { _tickRate = tickRate; }
50
51 private:
53 float _tickRate;
55 float _bufferedTime = 0.0f;
56};
57} // namespace Engine::Scheduler
The core is the place where all the data of the engine is stored. It contains the registry (entities)...
Definition Core.hpp:33
AScheduler(Core &core)
Constructor of the AScheduler class.
Definition AScheduler.hpp:20
float _bufferedTime
Buffered time since the last update, this allow to not lose time.
Definition FixedTimeUpdate.hpp:55
FixedTimeUpdate(Core &core, float tickRate=DEFAULT_TICK_RATE)
Constructor of the FixedTimeUpdate scheduler. It takes a reference to the core and an optional tick r...
Definition FixedTimeUpdate.hpp:32
static constexpr float DEFAULT_TICK_RATE
The default tick rate for the FixedTimeUpdate scheduler. It is set to 1/50 seconds,...
Definition FixedTimeUpdate.hpp:19
void RunSystems() override
Interface for the schedulers. A scheduler is responsible for running systems according to a specific ...
Definition FixedTimeUpdate.cpp:6
void SetTickRate(float tickRate)
Set the fixed tick rate.
Definition FixedTimeUpdate.hpp:49
float GetTickRate() const
Get the fixed tick rate.
Definition FixedTimeUpdate.hpp:41
float _tickRate
The tick rate correspond to the number of update the scheduler should do in a second.
Definition FixedTimeUpdate.hpp:53
Definition AScheduler.cpp:7