Make the positioning of the hand sprite dynamic bsed on size and also done once during init instead of every render.

This commit is contained in:
Zed A. Shaw 2026-05-27 12:20:35 -04:00
parent af69bd2286
commit af4ee30ade

View file

@ -20,6 +20,11 @@ namespace gui {
$hand = textures::get_sprite(config["player"]["hands"]);
$hand_anim = animation::load("assets/animation.json", config["player"]["hands"]);
int width = $hand_anim.sheet.frame_width;
int height = $hand_anim.sheet.frame_height;
$hand.sprite->setPosition({float(RAY_VIEW_X + (RAY_VIEW_WIDTH - width) / 2), float(RAY_VIEW_HEIGHT - height)});
}
void MainUI::dirty() {
@ -152,7 +157,6 @@ namespace gui {
if($hand_anim.playing) {
$hand_anim.update();
$hand_anim.apply(*$hand.sprite);
$hand.sprite->setPosition({RAY_VIEW_X, RAY_VIEW_Y});
$window.draw(*$hand.sprite);
}
}