0
0
mirror of https://github.com/Nimac0/SDL_Minigame synced 2026-01-12 22:23:43 +00:00

Readded animations

This commit is contained in:
Benedikt Galbavy 2024-11-05 16:14:35 +01:00
parent 476d24e930
commit d7f11e7ebd

View File

@ -64,6 +64,13 @@ void SpriteComponent::init()
void SpriteComponent::update() void SpriteComponent::update()
{ {
// This code is not compatible for animated tiles
if (animated) {
srcRect.x = srcRect.w * static_cast<int>((SDL_GetTicks() / speed) % frames);
srcRect.y = animationIndex * transform->height;
}
this->destRect.x = this->transform->position.x; this->destRect.x = this->transform->position.x;
this->destRect.y = this->transform->position.y; this->destRect.y = this->transform->position.y;
this->destRect.w = transform->width * transform->scale; this->destRect.w = transform->width * transform->scale;