From d7f11e7ebdb7174304d1a72c11b5daaf7571150c Mon Sep 17 00:00:00 2001 From: Benedikt Galbavy Date: Tue, 5 Nov 2024 16:14:35 +0100 Subject: [PATCH] Readded animations --- src/SpriteComponent.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/SpriteComponent.cpp b/src/SpriteComponent.cpp index b62c148..ae27ea7 100644 --- a/src/SpriteComponent.cpp +++ b/src/SpriteComponent.cpp @@ -64,6 +64,13 @@ void SpriteComponent::init() void SpriteComponent::update() { + // This code is not compatible for animated tiles + if (animated) { + srcRect.x = srcRect.w * static_cast((SDL_GetTicks() / speed) % frames); + + srcRect.y = animationIndex * transform->height; + } + this->destRect.x = this->transform->position.x; this->destRect.y = this->transform->position.y; this->destRect.w = transform->width * transform->scale;