|
@@ -22,9 +22,8 @@ namespace engine {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
game_dispatch::game_dispatch()
|
|
game_dispatch::game_dispatch()
|
|
|
- : screen_size(env::screen_size()),
|
|
|
|
|
- minimum_frame_duration(engine::fps::v60), scenes(),
|
|
|
|
|
- current_timestamp(clock::now()), curr_scene() {}
|
|
|
|
|
|
|
+ : screen_size(env::screen_size()), minimum_frame_duration(env::fps::v60),
|
|
|
|
|
+ scenes(), current_timestamp(env::clock::now()), curr_scene() {}
|
|
|
|
|
|
|
|
game_dispatch::current_scene_info::current_scene_info() {}
|
|
game_dispatch::current_scene_info::current_scene_info() {}
|
|
|
|
|
|
|
@@ -50,17 +49,12 @@ namespace engine {
|
|
|
{local_scene_position, mask(event::MOUSE_MASK, press)});
|
|
{local_scene_position, mask(event::MOUSE_MASK, press)});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- tick game_dispatch::get_tick() {
|
|
|
|
|
- timestamp now = clock::now();
|
|
|
|
|
- return {now, now - current_timestamp};
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
float game_dispatch::next_frame() {
|
|
float game_dispatch::next_frame() {
|
|
|
- tick t = get_tick();
|
|
|
|
|
|
|
+ env::clock::tick t(current_timestamp);
|
|
|
|
|
|
|
|
while (t.since < minimum_frame_duration) {
|
|
while (t.since < minimum_frame_duration) {
|
|
|
std::this_thread::sleep_for(minimum_frame_duration - t.since);
|
|
std::this_thread::sleep_for(minimum_frame_duration - t.since);
|
|
|
- t = get_tick();
|
|
|
|
|
|
|
+ t = env::clock::tick(current_timestamp);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
current_timestamp = t.now;
|
|
current_timestamp = t.now;
|