diff options
author | tom barrett <spalf0@gmail.com> | 2019-06-28 10:05:13 -0500 |
---|---|---|
committer | tom barrett <spalf0@gmail.com> | 2019-06-28 10:05:13 -0500 |
commit | 7d59cd2510ac926edd0790de4bffb0fbb9c60e7c (patch) | |
tree | 5b17c70031f57de3ba0f663018fdc41bad31f953 /src/math.rs | |
parent | 39ea81bea4a61baf8c95a33bcc979b0e65ce660e (diff) |
animation working
Diffstat (limited to 'src/math.rs')
-rw-r--r-- | src/math.rs | 9 |
1 files changed, 9 insertions, 0 deletions
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<Vec<(usize, Rect)>>, @@ -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) |