animation is now decoupled from sprite
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user