From 7d59cd2510ac926edd0790de4bffb0fbb9c60e7c Mon Sep 17 00:00:00 2001 From: tom barrett Date: Fri, 28 Jun 2019 10:05:13 -0500 Subject: animation working --- src/math.rs | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/math.rs') diff --git a/src/math.rs b/src/math.rs index b6f53ed..7599f87 100644 --- a/src/math.rs +++ b/src/math.rs @@ -6,6 +6,13 @@ pub fn convert_angle_to_rad(angle: f32) -> f32 { angle * (PI / 180.0) } +pub fn flip(rect: Rect) -> Rect { + let mut r = rect; + r.x *= -1.0; + r.x -= rect.w; + r +} + pub fn next_source( source: Rect, animation: &Option>, @@ -17,6 +24,8 @@ pub fn next_source( i = if i == animation.len() - 1 { 0 } else { i + 1 }; return (animation[i].1, Instant::now()); } + } else { + return (animation[0].1, Instant::now()); } } (source, timer) -- cgit v1.2.3