summaryrefslogtreecommitdiff
path: root/src/tileset.rs
diff options
context:
space:
mode:
authortom barrett <spalf0@gmail.com>2019-07-08 04:53:04 -0500
committertom barrett <spalf0@gmail.com>2019-07-08 04:53:04 -0500
commit503361ce70615d7c4b66bd7e49d56c61259dab32 (patch)
treea252975aaa2b34f4fcac81d8fdb5b11f8d36cf0e /src/tileset.rs
parentde4e8c1f0b82627fd1980401ae63472f49c9d89c (diff)
rotation now works
Diffstat (limited to 'src/tileset.rs')
-rw-r--r--src/tileset.rs18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/tileset.rs b/src/tileset.rs
index bb64c12..6a7ca42 100644
--- a/src/tileset.rs
+++ b/src/tileset.rs
@@ -64,13 +64,13 @@ impl Tileset {
for (id, tile) in tiles.clone().into_iter() {
for i in 1..8 {
let (new_id, new_tile) = match i {
- 1 => ((id | FLIP_H), tile.clone()),
- 2 => ((id | FLIP_V), flip(tile.clone())),
+ 1 => ((id | FLIP_H), flip(tile.clone())),
+ 2 => ((id | FLIP_V), tile.clone()),
3 => ((id | FLIP_D), tile.clone()),
- 4 => ((id | FLIP_D | FLIP_H), tile.clone()),
- 5 => ((id | FLIP_D | FLIP_V), tile.clone()),
- 6 => ((id | FLIP_H | FLIP_V), tile.clone()),
- 7 => ((id | FLIP_A), tile.clone()),
+ 4 => ((id | FLIP_D | FLIP_H), rotate(tile.clone(), 90.0)),
+ 5 => ((id | FLIP_D | FLIP_V), rotate(tile.clone(), 270.0)),
+ 6 => ((id | FLIP_H | FLIP_V), rotate(tile.clone(), 180.0)),
+ 7 => ((id | FLIP_A), rotate(tile.clone(), 90.0)),
_ => (0, Tile::default()),
};
@@ -135,3 +135,9 @@ fn flip(tile: Tile) -> Tile {
t.source.x -= t.source.w;
t
}
+
+fn rotate(tile: Tile, angle: f32) -> Tile {
+ let mut t = tile.clone();
+ t.properties.rotation = convert_angle_to_rad(angle);
+ t
+}