Mercurial > games > semicongine
changeset 842:611f9cee7495
fix: more animation issues
author | Sam <sam@basx.dev> |
---|---|
date | Mon, 27 Nov 2023 23:14:09 +0700 |
parents | d02a66171917 |
children | 1c3e74f24db0 |
files | src/semicongine/animation.nim |
diffstat | 1 files changed, 4 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- 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