aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/api/Engine.cpp
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-12-11 21:19:57 +0100
committerLoek Le Blansch <loek@pipeframe.xyz>2024-12-11 21:19:57 +0100
commit000062b462a3af86db4dac4d8c9e5ef32feb2996 (patch)
treed766704f5862520ead6a03656103dd2fbcce99e9 /src/crepe/api/Engine.cpp
parent359ad8db97305856f4cfdade1cd1dada78a7a635 (diff)
split up loopmanager into SystemManager and Engine
Diffstat (limited to 'src/crepe/api/Engine.cpp')
-rw-r--r--src/crepe/api/Engine.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/crepe/api/Engine.cpp b/src/crepe/api/Engine.cpp
new file mode 100644
index 0000000..8ed55fa
--- /dev/null
+++ b/src/crepe/api/Engine.cpp
@@ -0,0 +1,37 @@
+#include "Engine.h"
+
+using namespace crepe;
+using namespace std;
+
+void Engine::start() {
+ this->setup();
+ this->loop();
+}
+
+void Engine::setup() {
+ LoopTimer & timer = this->loop_timer;
+ this->game_running = true;
+ this->scene_manager.load_next_scene();
+ timer.start();
+ timer.set_fps(200);
+}
+
+void Engine::loop() {
+ LoopTimer & timer = this->loop_timer;
+ SystemManager & systems = this->system_manager;
+
+ timer.start();
+
+ while (game_running) {
+ timer.update();
+
+ while (timer.get_lag() >= timer.get_fixed_delta_time()) {
+ systems.fixed_update();
+ timer.advance_fixed_update();
+ }
+
+ systems.frame_update();
+ timer.enforce_frame_rate();
+ }
+}
+