Animations are now being pulled correctly but I need to add a timing concept to animations instead of ticks.

This commit is contained in:
Zed A. Shaw 2025-10-10 00:25:37 -04:00
parent 517de91a5b
commit c33f370572
10 changed files with 43 additions and 22 deletions

View file

@ -1,6 +1,7 @@
#include "boss/ui.hpp"
#include "constants.hpp"
#include "components.hpp"
#include "animation.hpp"
namespace boss {
using namespace guecs;
@ -18,6 +19,9 @@ namespace boss {
$floor_sprite = textures::get_sprite(*$scene.floor);
$player_sprite = textures::get_sprite($scene.player["sprite"]);
dbc::check(animation::has(sprite.name), "add boss animation to animations.json");
$boss_anim = animation::load(sprite.name);
}
void UI::init() {
@ -92,12 +96,19 @@ namespace boss {
}
void UI::move_boss(const std::string& cell_name) {
dbc::log(cell_name);
position_sprite($boss_sprite, cell_name, $scene.boss["scale"], $scene.boss["mid_cell"]);
auto& cell = $arena.cell_for(cell_name);
$boss_pos = {float(cell.mid_x), float(cell.mid_y)};
}
void UI::move_player(const std::string& cell_name) {
dbc::log(cell_name);
position_sprite($player_sprite, cell_name, $scene.player["scale"], $scene.player["mid_cell"]);
}
void UI::play_animations() {
if($boss_anim.playing) {
animation::apply($boss_anim, *$boss_sprite.sprite, $boss_pos);
}
}
}