Skip to content

Commit

Permalink
clamp value while animating
Browse files Browse the repository at this point in the history
  • Loading branch information
griffi-gh committed Oct 8, 2023
1 parent 66ad7bb commit 4ab081e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion yarge-frontend-sdl/src/anim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ impl Animatable {
if (self.target - self.value).abs() < EPSILON {
self.value = self.target;
} else {
self.value = self.value + (self.target - self.value) * (self.speed * s);
self.value = {
(self.value + (self.target - self.value) * (self.speed * s))
.clamp(self.value.min(self.target), self.value.max(self.target))
};
}
}
pub fn is_animating(&self) -> bool {
Expand Down

0 comments on commit 4ab081e

Please sign in to comment.