refactor: make UpdateSpriteRotation more generic

This commit is contained in:
huaqo-games
2025-11-06 11:31:18 +01:00
parent 56748f1fd8
commit 6a1dd65bd4
+2 -7
View File
@@ -13,14 +13,9 @@ void UpdateSpriteDestRec(Sprite *sprite, const Vector2 *vector)
sprite->destRec.y = vector->y; sprite->destRec.y = vector->y;
} }
void UpdateSpriteRotation(Sprite *sprite, Vector2 *vector) void UpdateSpriteRotation(Sprite *sprite, float rotation)
{ {
if (Vector2Length(*vector) <= 0.0f) sprite->rotation = Lerp(sprite->rotation, rotation, 0.1f);
{
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) void RenderSprite(const Sprite *sprite)