BossFightUI now gets everything from a world and will be implemented like the rest of the game, but as a mini game.

This commit is contained in:
Zed A. Shaw 2025-03-03 12:44:26 -05:00
parent ca18422930
commit 6e8aa48332
4 changed files with 34 additions and 25 deletions

View file

@ -5,9 +5,10 @@
namespace gui {
using namespace guecs;
BossFightUI::BossFightUI(DinkyECS::World& world, std::string boss_name)
: $config(world.get_the<components::GameConfig>()),
$boss_name(boss_name)
BossFightUI::BossFightUI(shared_ptr<DinkyECS::World> world, DinkyECS::Entity boss_id)
: $world(world),
$boss_id(boss_id),
$config(world->get_the<components::GameConfig>())
{
$status.position(0, 0, BOSS_VIEW_X, SCREEN_HEIGHT);
$status.layout(
@ -24,15 +25,13 @@ namespace gui {
"[overlay_9|overlay_10|overlay_12]"
"[overlay_13|overlay_14|overlay_16]");
$sounds = components::get<components::Sound>($config.bosses[boss_name]);
$combat = components::get<components::Combat>($config.bosses[boss_name]);
$weapon_hit_sound = $config.bosses[$boss_name]["weapon_sound"];
$sounds = $world->get<components::Sound>($boss_id);
$combat = $world->get<components::Combat>($boss_id);
}
void BossFightUI::configure_sprite() {
auto& boss = $config.bosses[$boss_name];
$sprite_config = components::get<components::Sprite>(boss);
$animation = components::get<components::Animation>(boss);
$sprite_config = $world->get<components::Sprite>($boss_id);
$animation = $world->get<components::Animation>($boss_id);
$animation.texture_width = $sprite_config.width;
$boss_image = textures::get($sprite_config.name);
@ -48,8 +47,10 @@ namespace gui {
}
void BossFightUI::configure_background() {
auto& boss = $config.bosses[$boss_name];
$boss_background = textures::get(boss["background"]);
// FIX ME
// auto& config = $world->get_the<components::GameConfig>();
std::string boss_bg = "boss_fight_background";
$boss_background = textures::get(boss_bg);
$boss_background.sprite->setPosition({BOSS_VIEW_X, BOSS_VIEW_Y});
$status.world().set_the<Background>({$status.$parser});
}
@ -96,10 +97,6 @@ namespace gui {
sound::play($sounds.attack);
}
if(!sound::playing($weapon_hit_sound) && $animation.subframe > 1.2 && $animation.subframe < 1.5) {
sound::play($weapon_hit_sound);
}
$boss_image.sprite->setTextureRect(frame_rect);
window.draw(*$boss_image.sprite);
}