animation is now decoupled from sprite

This commit is contained in:
huaqo-games
2025-02-08 17:47:12 +01:00
parent 0c73d94187
commit bcb1577694
7 changed files with 121 additions and 4 deletions
+9
View File
@@ -1,6 +1,7 @@
#ifndef SPRITE_H
#define SPRITE_H
#include <raylib.h>
#include <raymath.h>
typedef struct {
Texture2D texture;
@@ -22,6 +23,14 @@ void UpdateSpriteDestRec(Sprite *sprite, const Vector2 *vector){
sprite->destRec.y = vector->y;
}
void UpdateSpriteRotation(Sprite *sprite, Vector2 *vector){
if(Vector2Length(*vector) <= 0.0f){
return;
}
float targetRotation = (float)atan2(vector->y, vector->x) * (180.0f / PI) + 90.0f;
sprite->rotation = Lerp(sprite->rotation, targetRotation, 0.1f);
}
void RenderSprite(const Sprite *sprite){
DrawTexturePro(
sprite->texture,