Made a terrible animation sprite and then did a quick animation test. Won't keep it for now but this shows how it could work.

This commit is contained in:
Zed A. Shaw 2025-01-25 12:02:57 -05:00
parent 0882851b3f
commit 51858ea399
6 changed files with 9 additions and 4 deletions

View file

@ -148,7 +148,9 @@ void Raycaster::sprite_casting() {
int texY = ((d * textureHeight) / spriteHeight) / textureHeight;
sf_sprite->setScale({sprite_w, sprite_h});
sf_sprite->setTextureRect(sf::IntRect({texX, texY}, {texX_end - texX, textureHeight}));
auto time = $clock.getElapsedTime();
int frame = int(time.asMicroseconds() / 200.0) % 4;
sf_sprite->setTextureRect(sf::IntRect({texX + (textureWidth * frame), texY}, {texX_end - texX, textureHeight}));
sf_sprite->setPosition({x, y});
$window.draw(*sf_sprite);
}