summaryrefslogtreecommitdiff
path: root/src/tile.rs
diff options
context:
space:
mode:
authortom barrett <spalf0@gmail.com>2019-06-28 10:05:13 -0500
committertom barrett <spalf0@gmail.com>2019-06-28 10:05:13 -0500
commit7d59cd2510ac926edd0790de4bffb0fbb9c60e7c (patch)
tree5b17c70031f57de3ba0f663018fdc41bad31f953 /src/tile.rs
parent39ea81bea4a61baf8c95a33bcc979b0e65ce660e (diff)
animation working
Diffstat (limited to 'src/tile.rs')
-rw-r--r--src/tile.rs13
1 files changed, 3 insertions, 10 deletions
diff --git a/src/tile.rs b/src/tile.rs
index a367592..c8c2ae7 100644
--- a/src/tile.rs
+++ b/src/tile.rs
@@ -3,7 +3,7 @@ use ggez::nalgebra::{Point2, Vector2};
use std::time::Instant;
use crate::constants;
-use crate::math::{convert_angle_to_rad, next_source};
+use crate::math::{convert_angle_to_rad, flip, next_source};
use crate::tileset::Tileset;
pub struct Tile {
@@ -29,12 +29,12 @@ impl Tile {
};
let (source, rotation) = match (flip_d, flip_h, flip_v) {
- (true, true, true) => (Tile::flip(tileset.get(id)), convert_angle_to_rad(90.0)),
+ (true, true, true) => (flip(tileset.get(id)), convert_angle_to_rad(90.0)),
(true, true, false) => (tileset.get(id), convert_angle_to_rad(90.0)),
(true, false, true) => (tileset.get(id), convert_angle_to_rad(270.0)),
//(true, false, false) => (),
(false, true, true) => (tileset.get(id), convert_angle_to_rad(180.0)),
- (false, true, false) => (Tile::flip(tileset.get(id)), 0.0),
+ (false, true, false) => (flip(tileset.get(id)), 0.0),
//(false, false, true) => (),
//(false, false, false) => (),
_ => (tileset.get(id), 0.0),
@@ -58,13 +58,6 @@ impl Tile {
}
}
- fn flip(rect: Rect) -> Rect {
- let mut r = rect;
- r.x *= -1.0;
- r.x -= rect.w;
- r
- }
-
pub fn update(&mut self) {
let (source, timer) = next_source(self.source, &self.animation, self.timer);
self.source = source;