File tree Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Original file line number Diff line number Diff line change 1
1
#include < imgui.h>
2
2
#include < app.hpp>
3
3
#include < djson/json.hpp>
4
+ #include < game.hpp>
5
+ #include < klib/visitor.hpp>
4
6
#include < log.hpp>
5
7
6
8
namespace miracle {
@@ -19,13 +21,22 @@ App::App() : m_context(context_ci), m_data_loader(le::FileDataLoader::upfind("as
19
21
}
20
22
21
23
void App::run () {
22
- while (m_context.is_running ()) {
23
- m_context.next_frame ();
24
+ auto game = Game{&m_services};
24
25
25
- ImGui::ShowDemoWindow ();
26
+ auto const event_visitor = klib::SubVisitor{
27
+ [&game](le::event::CursorPos const & cursor_pos) { game.on_cursor_pos (cursor_pos); },
28
+ };
26
29
30
+ auto delta_time = kvf::DeltaTime{};
31
+ while (m_context.is_running ()) {
32
+ m_context.next_frame ();
33
+ auto const dt = delta_time.tick ();
34
+ for (auto const & event : m_context.event_queue ()) { std::visit (event_visitor, event); }
35
+ game.tick (dt);
36
+ if (auto renderer = m_context.begin_render ()) { game.render (renderer); }
27
37
m_context.present ();
28
38
}
39
+ m_context.wait_idle ();
29
40
}
30
41
31
42
void App::bind_services () {
You can’t perform that action at this time.
0 commit comments