Boss fight now has combat stats and damage so I can now have a boss fight.

This commit is contained in:
Zed A. Shaw 2025-11-22 00:50:47 -05:00
parent 8ee3e8736f
commit 63a17d7efa
7 changed files with 58 additions and 9 deletions

View file

@ -3,14 +3,19 @@
#include "constants.hpp"
#include "components.hpp"
#include "animation.hpp"
#include <fmt/xchar.h>
#include "game_level.hpp"
namespace boss {
using namespace guecs;
using namespace DinkyECS;
UI::UI(components::AnimatedScene& scene, Entity boss_id) :
UI::UI(shared_ptr<World> world, Entity boss_id, Entity player_id) :
$world(world),
$boss_id(boss_id),
$player_id(player_id),
$combat_ui(true),
$arena(scene),
$arena(world->get<components::AnimatedScene>($boss_id)),
$view_texture({BOSS_VIEW_WIDTH, BOSS_VIEW_HEIGHT}),
$view_sprite($view_texture.getTexture())
{
@ -33,7 +38,7 @@ namespace boss {
auto stats = $actions.entity("stats");
$actions.set<Rectangle>(stats, {});
$actions.set<Text>(stats, {L"stats"});
update_stats();
$actions.init();
@ -41,6 +46,14 @@ namespace boss {
$combat_ui.init(cell.x, cell.y, cell.w, cell.h);
}
void UI::update_stats() {
auto& player_combat = $world->get<components::Combat>($player_id);
auto& boss_combat = $world->get<components::Combat>($boss_id);
$actions.show_text("stats", fmt::format(
L"PLAYER: {}\nBOSS: {}", player_combat.hp, boss_combat.hp));
}
void UI::render(sf::RenderWindow& window) {
$actions.render(window);
$combat_ui.render(window);