Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 22 additions & 18 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ int main()

// todo -iwad param, build iwad dirs, choose iwad file

fmt::print("Initializing wad files\n");
fmt::print("Initializing WAD files\n");

const auto [iwad_path, iwad] = core::find_iwad();

Expand All @@ -140,29 +140,33 @@ int main()
auto menu_sys = menu::system(iwad, game_sys);

auto gfx_sys = grfx::system({}, data);
bool running = true;

core::event_queue events;
while (true)
while (running)
{
sdl_get_events(events);

while (const auto e = events.pop())
{
if (std::holds_alternative<core::quit_event>(*e))
{
sdl_get_events(events);
running = false;
break;
}

process_events(events, menu_sys, game_sys);
if (!menu_sys.handle_event(*e))
game_sys.handle_event(*e);
}

game_sys.tick();
if (!running) break;

game_sys.draw(gfx_sys, data);
game_sys.tick();

menu_sys.draw(gfx_sys, data);
gfx_sys.update();
}
}
catch (std::exception& e)
{
fmt::print("Shut down due to error: {}\n", e.what());
return -1;
}
catch (...)
{
game_sys.draw(gfx_sys, data);
menu_sys.draw(gfx_sys, data);

gfx_sys.update();
}
fmt::print("Shut down due to unknown error\n");
return -1;
}
Expand Down