summaryrefslogtreecommitdiff
path: root/src/tileset.rs
diff options
context:
space:
mode:
authortom barrett <spalf0@gmail.com>2019-07-10 09:43:48 -0500
committertom barrett <spalf0@gmail.com>2019-07-10 09:43:48 -0500
commitced37025a37051db896443d310f5f613f1281882 (patch)
tree6faa646addcd2cfa1c49154a06846321a6e2e423 /src/tileset.rs
parent503361ce70615d7c4b66bd7e49d56c61259dab32 (diff)
animation now always works, added player spawn
Diffstat (limited to 'src/tileset.rs')
-rw-r--r--src/tileset.rs20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/tileset.rs b/src/tileset.rs
index 6a7ca42..effba3b 100644
--- a/src/tileset.rs
+++ b/src/tileset.rs
@@ -65,8 +65,8 @@ impl Tileset {
for i in 1..8 {
let (new_id, new_tile) = match i {
1 => ((id | FLIP_H), flip(tile.clone())),
- 2 => ((id | FLIP_V), tile.clone()),
- 3 => ((id | FLIP_D), tile.clone()),
+ //2 => ((id | FLIP_V), tile.clone()),
+ //3 => ((id | FLIP_D), 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)),
@@ -95,7 +95,9 @@ impl Tileset {
let first_tile = self
.tiles
.iter()
- .find(|(id, _)| id == &&tile_id)
+ .find(
+ |(id, _)| id == &&tile_id
+ )
.unwrap()
.1
.clone();
@@ -105,8 +107,13 @@ impl Tileset {
self.tiles
.values()
.cloned()
- .filter(|t| t.properties.entity == first_tile.properties.entity)
- .collect(),
+ .filter(|t| {
+ t.properties.entity == first_tile.properties.entity
+ && (t.properties.rotation - first_tile.properties.rotation) < constants::FLOAT_PRECISION
+ && t.source.x.is_sign_positive() == first_tile.source.x.is_sign_positive()
+ && t.source.y.is_sign_positive() == first_tile.source.y.is_sign_positive()
+ })
+ .collect()
)
} else {
Animation::new(vec![first_tile])
@@ -119,6 +126,9 @@ impl Tileset {
.find(|t| {
t.properties.entity == Some(entity.to_string())
&& Some(keyframe) == t.properties.keyframe
+ && t.properties.rotation == 0.0
+ && t.source.x > 0.0
+ && t.source.y > 0.0
})
.unwrap()
.clone()