summaryrefslogtreecommitdiff
path: root/src/tile.rs
diff options
context:
space:
mode:
authortom barrett <spalf0@gmail.com>2019-07-13 04:51:26 -0500
committertom barrett <spalf0@gmail.com>2019-07-13 04:51:26 -0500
commit9443ea856a706654916f0905d346c1e2c9d500c4 (patch)
tree027b69e10c482337cfc1109c58c50fdf32fa8c04 /src/tile.rs
parentb4e83e63d46fdbc40f548bfa9bd95d7ed9912b8d (diff)
less code
Diffstat (limited to 'src/tile.rs')
-rw-r--r--src/tile.rs23
1 files changed, 18 insertions, 5 deletions
diff --git a/src/tile.rs b/src/tile.rs
index de67cdc..e651f4a 100644
--- a/src/tile.rs
+++ b/src/tile.rs
@@ -1,5 +1,6 @@
use ggez::graphics::Rect;
use xml::reader::XmlEvent;
+use std::f32::consts::PI;
use crate::xmlelements::XMLElements;
@@ -13,11 +14,6 @@ impl Tile {
pub fn new(source: Rect, properties: Properties) -> Tile {
Tile { source, properties }
}
-
- pub fn flip(&mut self) {
- self.source.x *= -1.0;
- self.source.x -= self.source.w;
- }
}
impl Default for Tile {
@@ -79,3 +75,20 @@ impl Default for Properties {
}
}
}
+
+pub fn convert_angle_to_rad(angle: f32) -> f32 {
+ angle * (PI / 180.0)
+}
+
+pub fn flip(tile: Tile) -> Tile {
+ let mut t = tile.clone();
+ t.source.x *= -1.0;
+ t.source.x -= t.source.w;
+ t
+}
+
+pub fn rotate(tile: Tile, angle: f32) -> Tile {
+ let mut t = tile.clone();
+ t.properties.rotation = convert_angle_to_rad(angle);
+ t
+}