Animations are refactored to let me spawn in an 'attack animation' but I think the data model is wrong. Rather than spawning in an animation every time I can probably just make one, reposition it, then tell it to play. I'll have to try it.

This commit is contained in:
Zed A. Shaw 2025-09-12 11:56:11 -04:00
parent 8384b11993
commit ad3e580495
15 changed files with 109 additions and 56 deletions

View file

@ -108,7 +108,6 @@ void Raycaster::sprite_casting(sf::RenderTarget &target) {
auto world = $level.world;
$level.collision->distance_sorted($sprite_order, {(size_t)$pos_x, (size_t)$pos_y}, RENDER_DISTANCE);
// after sorting the sprites, do the projection
for(auto& rec : $sprite_order) {
if(!$sprites.contains(rec.entity)) continue;
@ -184,6 +183,10 @@ void Raycaster::sprite_casting(sf::RenderTarget &target) {
int d = y * texture_height - $height * half_height + sprite_height * half_height;
int tex_y = ((d * texture_height) / sprite_height) / texture_height;
// BUG: this data could be put into the world
// as frame data, then just have a system that
// constantly applies this to any sprite that
// has an animation and is visible
sf::Vector2f origin{texture_width / 2.0f, texture_height / 2.0f};
sf::Vector2f scale{sprite_scale_w, sprite_scale_h};
sf::Vector2f position{x + origin.x * scale.x, y + origin.y * scale.y};