# HG changeset patch # User Sam # Date 1701101649 -25200 # Node ID ade6e9324ae0cbc17092b2ab273db12d959b8e2b # Parent 8e320c8537c77b36499c99eabb9207d7910c8269 fix: more animation issues diff -r 8e320c8537c7 -r ade6e9324ae0 src/semicongine/animation.nim --- a/src/semicongine/animation.nim Mon Nov 27 21:31:34 2023 +0700 +++ b/src/semicongine/animation.nim Mon Nov 27 23:14:09 2023 +0700 @@ -149,11 +149,10 @@ # TODO: check this function, not 100% correct I think if player.playing: player.currentTime += float32(player.currentDirection) * dt - if player.currentTime > player.animation.duration: + if not (0 <= player.currentTime and player.currentTime < player.animation.duration): dec player.currentIteration # last iteration reached if player.currentIteration <= 0 and player.animation.iterations != 0: - player.currentTime = player.animation.duration player.stop() # more iterations else: @@ -166,5 +165,7 @@ player.currentDirection = -player.currentDirection player.currentTime += float32(player.currentDirection) * dt * 2'f32 - player.currentValue = player.animation.animationFunction(player.currentTime / player.animation.duration) + player.currentValue = player.animation.animationFunction( + max(low(AnimationTime), min(player.currentTime / player.animation.duration, high(AnimationTime))) + ) return player.currentValue