The whole boss fight scene is now configurable with json.

This commit is contained in:
Zed A. Shaw 2025-09-27 11:58:44 -04:00
parent 06f6098281
commit 06a174040f
5 changed files with 29 additions and 43 deletions

View file

@ -8,23 +8,23 @@ namespace boss {
UI::UI(shared_ptr<World> world, Entity boss_id) :
$world(world),
$boss_id(boss_id),
$scene(world->get<components::BossFight>($boss_id)),
$combat_ui(true)
{
auto& sprite = world->get<components::Sprite>($boss_id);
auto& sprite = $world->get<components::Sprite>($boss_id);
$boss_sprite = textures::get_sprite(sprite.name);
auto& boss_conf = world->get<components::BossFight>($boss_id);
// floor is std::optional
$floor_sprite = textures::get_sprite(*boss_conf.floor);
$floor_sprite = textures::get_sprite(*$scene.floor);
$player_sprite = textures::get_sprite("test_player");
$player_sprite = textures::get_sprite($scene.player["sprite"]);
}
void UI::init() {
$arena.position(SCREEN_WIDTH-BOSS_VIEW_WIDTH,0, BOSS_VIEW_WIDTH, SCREEN_HEIGHT);
$arena.set<Background>($arena.MAIN, {$arena.$parser, THEME.DARK_MID});
auto& background = $arena.get<Background>($arena.MAIN);
background.set_sprite("test_background", true);
background.set_sprite($scene.background, true);
$arena.layout(
"[_ |boss1 |boss2 |boss3 |boss4 |_]"
@ -35,9 +35,9 @@ namespace boss {
"[floor4|player5|player6|player7|player8|_]"
);
position_sprite($boss_sprite, "boss3", 0.7, true);
position_sprite($player_sprite, "player2", 0.5, false);
position_sprite($floor_sprite, "floor1", 1.0, false);
position_sprite($boss_sprite, $scene.boss["start_pos"], $scene.boss["scale"], $scene.boss["mid_cell"]);
position_sprite($player_sprite, $scene.player["start_pos"], $scene.player["scale"], $scene.player["mid_cell"]);
position_sprite($floor_sprite, $scene.floor_pos, 1.0, false);
$arena.init();

View file

@ -6,6 +6,10 @@
#include "textures.hpp"
#include "gui/combat_ui.hpp"
namespace components {
struct BossFight;
}
namespace boss {
using std::shared_ptr;
using namespace DinkyECS;
@ -14,6 +18,7 @@ namespace boss {
struct UI {
shared_ptr<World> $world = nullptr;
Entity $boss_id = NONE;
components::BossFight& $scene;
gui::CombatUI $combat_ui;
SpriteTexture $boss_sprite;
SpriteTexture $player_sprite;