From 8f8802f3879210f75514f8c166157fff1889a5ea Mon Sep 17 00:00:00 2001 From: Josh Deprez Date: Sat, 31 Jul 2021 19:20:36 +1000 Subject: [PATCH] loop -> oneshot --- engine/anim.go | 8 ++++---- main.go | 2 -- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/engine/anim.go b/engine/anim.go index 84c5502..ead2cf9 100644 --- a/engine/anim.go +++ b/engine/anim.go @@ -13,7 +13,7 @@ func (a *Anim) CurrentFrame() int { return a.Def.Frames[a.Index].Frame } // Update increments the tick count and advances the frame if necessary. func (a *Anim) Update() error { a.Ticks++ - if !a.Def.Loop && a.Index == len(a.Def.Frames)-1 { + if a.Def.OneShot && a.Index == len(a.Def.Frames)-1 { // on the last frame of a one shot so remain on final frame return nil } @@ -21,7 +21,7 @@ func (a *Anim) Update() error { a.Ticks = 0 a.Index++ } - if a.Def.Loop && a.Index >= len(a.Def.Frames) { + if !a.Def.OneShot && a.Index >= len(a.Def.Frames) { a.Index = 0 } return nil @@ -29,8 +29,8 @@ func (a *Anim) Update() error { // AnimDef describes an animation (sequence of frames and timings). type AnimDef struct { - Frames []AnimFrame `json:"frames"` - Loop bool `json:"loop"` + Frames []AnimFrame `json:"frames"` + OneShot bool `json:"oneshot"` } // AnimFrame describes a frame in an animation. diff --git a/main.go b/main.go index db42c41..fe6b834 100644 --- a/main.go +++ b/main.go @@ -54,7 +54,6 @@ func main() { {Frame: 1, Duration: 16}, {Frame: 2, Duration: 16}, }, - Loop: true, }, }, } @@ -67,7 +66,6 @@ func main() { {Frame: 5, Duration: 12}, {Frame: 6, Duration: 12}, }, - Loop: true, }, }, }