Owns the ECS world and runs the main loop of a game.
More...
#include <GameEngine.hpp>
|
|
using | Clock = std::chrono::steady_clock |
| | Monotonic clock used to measure frame times.
|
| |
|
| ecs::Registry & | registry () |
| | Returns the entity and component registry.
|
| |
| ecs::Scheduler & | scheduler () |
| | Returns the system scheduler.
|
| |
| busEvent & | eventBus () |
| | Returns the event bus shared by the systems.
|
| |
|
void | stop () |
| | Asks the main loop to exit after the current frame.
|
| |
| void | setFPS (uint32_t fps) |
| | Sets the frame rate cap.
|
| |
| template<Game TGame> |
| int | run (TGame &game) |
| | Loads the game and runs frames until it stops.
|
| |
Owns the ECS world and runs the main loop of a game.
◆ registry()
| ecs::Registry & rtk::GameEngine::registry |
( |
| ) |
|
|
inline |
Returns the entity and component registry.
- Returns
- The registry.
◆ scheduler()
| ecs::Scheduler & rtk::GameEngine::scheduler |
( |
| ) |
|
|
inline |
Returns the system scheduler.
- Returns
- The scheduler.
◆ eventBus()
| busEvent & rtk::GameEngine::eventBus |
( |
| ) |
|
|
inline |
Returns the event bus shared by the systems.
- Returns
- The event bus.
◆ setFPS()
| void rtk::GameEngine::setFPS |
( |
uint32_t | fps | ) |
|
|
inline |
Sets the frame rate cap.
- Parameters
-
| fps | Frames per second, 0 for no cap. |
◆ run()
template<Game TGame>
| int rtk::GameEngine::run |
( |
TGame & | game | ) |
|
|
inline |
Loads the game and runs frames until it stops.
Each frame calls onUpdate on the game, runs every system with the elapsed time clamped to 0.25 s, flushes the registry and then sleeps to respect the frame rate cap.
- Template Parameters
-
- Parameters
-
- Returns
- 0 when the loop ends normally.