Boss fight is now working. Turned out to be something really dumb.

This commit is contained in:
Zed A. Shaw 2025-12-19 12:04:51 -05:00
parent 4958f24c1d
commit 4b4f9b3916
8 changed files with 154 additions and 127 deletions

View file

@ -1,4 +1,3 @@
#include "gui/fsm.hpp"
#include "textures.hpp"
#include "sound.hpp"
#include "autowalker.hpp"
@ -36,8 +35,6 @@ int main(int, char*[]) {
if(FRAME_LIMIT) window.setFramerateLimit(FRAME_LIMIT);
window.setPosition({0,0});
gui::routing::Router router;
sound::mute(true);
sound::play("ambient_1", true);
@ -45,25 +42,16 @@ int main(int, char*[]) {
craft_weapon();
auto main = boss::System::create_bossfight();
main->set_window(&window);
auto world = GameDB::current_world();
dbc::check(main->$world == world, "GameDB::current_world doesn't match boss fight world.");
while(!main->in_state(boss::State::END)) {
main->mouse_pos = window.mapPixelToCoords(router.position);
while(const auto ev = window.pollEvent()) {
auto gui_ev = router.process_event(ev);
if(gui_ev == game::Event::QUIT || main->event(gui_ev, {})) {
return 0;
} else {
main->event(game::Event::TICK, {});
}
}
if(main->$world->has_event<game::Event>()) {
main->handle_world_events();
dbc::check(!main->$world->has_event<game::Event>(), "You didn't eat all the events.");
if(main->handle_keyboard_mouse() ||
main->handle_world_events())
{
return 0;
}
main->render(window);