package animation import rl "github.com/gen2brain/raylib-go/raylib" type animationTracker struct { currentAnimation entityAnimation animationStep int } func NewAnimationTracker() *animationTracker { return &animationTracker{} } func (a *animationTracker) Draw(windowPosition rl.Vector2, color rl.Color) error { step := a.animationStep / a.currentAnimation.GetSpeed() err := a.currentAnimation.Draw(step, windowPosition, color) if err != nil { return err } a.animationStep = 1 + a.animationStep return nil } func (a *animationTracker) SetAnimation(id int) { newAnim := AnimationMap[id] if newAnim != a.currentAnimation { a.animationStep = 0 } a.currentAnimation = newAnim }