aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/api/Engine.cpp
blob: 8ed55fadd433e288a79e262daf37d3fb392bcdd6 (plain)
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
#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();
	}
}