Making the bossfight function by creating the FSM for it.

This commit is contained in:
Zed A. Shaw 2025-09-27 13:25:34 -04:00
parent 06a174040f
commit 231adb6335
3 changed files with 23 additions and 3 deletions

View file

@ -53,6 +53,7 @@ namespace boss {
auto stats = $actions.entity("stats");
$actions.set<Rectangle>(stats, {});
$actions.set<Text>(stats, {L"stats"});
$actions.set<Effect>(stats, {});
$actions.init();
@ -70,20 +71,28 @@ namespace boss {
}
void UI::render(sf::RenderWindow& window) {
$arena.render(window);
$actions.render(window);
$combat_ui.render(window);
$arena.render(window);
window.draw(*$floor_sprite.sprite);
window.draw(*$boss_sprite.sprite);
window.draw(*$player_sprite.sprite);
// $arena.debug_layout(window);
}
bool UI::mouse(float x, float y, Modifiers mods) {
return $actions.mouse(x, y, mods);
return $arena.mouse(x, y, mods)
|| $combat_ui.mouse(x, y, mods)
|| $actions.mouse(x, y, mods);
}
bool UI::boss_dead() {
return false;
}
void UI::run_systems() {
// does nothing yet
}
}

View file

@ -33,5 +33,6 @@ namespace boss {
bool mouse(float x, float y, guecs::Modifiers mods);
void position_sprite(SpriteTexture& st, const std::string& name, float scale, bool at_mid=false);
bool boss_dead();
void run_systems();
};
}

View file

@ -226,8 +226,18 @@ namespace gui {
event(Event::BOSS_END);
}
} break;
case ATTACK:
fmt::println("ATTACK THE BOSS!");
break;
case MOUSE_MOVE: {
sf::Vector2f pos = mouse_position();
$boss_fight_ui->mouse(pos.x, pos.y, {1 << guecs::ModBit::hover});
} break;
case TICK:
$boss_fight_ui->run_systems();
break;
default:
break; // do nothing for now
fmt::println("BOSS_FIGHT unknown event {}", (int)ev);
}
}