diff options
-rw-r--r-- | resources/map.tmx | 10 | ||||
-rw-r--r-- | resources/tileset.png | bin | 9673 -> 10252 bytes | |||
-rw-r--r-- | resources/tileset.tsx | 28 | ||||
-rw-r--r-- | src/tile.rs | 11 |
4 files changed, 39 insertions, 10 deletions
diff --git a/resources/map.tmx b/resources/map.tmx index bbc808e..766cd89 100644 --- a/resources/map.tmx +++ b/resources/map.tmx @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<map version="1.2" tiledversion="1.2.3" orientation="orthogonal" renderorder="right-down" width="20" height="20" tilewidth="16" tileheight="16" infinite="0" nextlayerid="6" nextobjectid="1"> +<map version="1.2" tiledversion="1.2.1" orientation="orthogonal" renderorder="right-down" width="20" height="20" tilewidth="16" tileheight="16" infinite="0" nextlayerid="6" nextobjectid="1"> <tileset firstgid="1" name="tileset" tilewidth="16" tileheight="16" tilecount="50" columns="10"> <image source="tileset.png" width="160" height="80"/> </tileset> @@ -75,13 +75,13 @@ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 </data> </layer> - <layer id="5" name="People" width="20" height="20"> + <layer id="4" name="Person" width="20" height="20"> <data encoding="csv"> 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,35,0,0,2147483683,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,45,3758096429,3758096419,2147483693,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,2147483683,0,0,35,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,2147483693,0,0,45,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, @@ -99,7 +99,7 @@ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 </data> </layer> - <layer id="4" name="Flames" width="20" height="20"> + <layer id="5" name="Flame" width="20" height="20"> <data encoding="csv"> 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, diff --git a/resources/tileset.png b/resources/tileset.png Binary files differindex 01261d0..56f2cce 100644 --- a/resources/tileset.png +++ b/resources/tileset.png diff --git a/resources/tileset.tsx b/resources/tileset.tsx index 2672ec2..67229a4 100644 --- a/resources/tileset.tsx +++ b/resources/tileset.tsx @@ -15,4 +15,32 @@ <property name="keyframe" type="int" value="1"/> </properties> </tile> + <tile id="34"> + <properties> + <property name="delay" type="int" value="100"/> + <property name="entity" value="player-top"/> + <property name="keyframe" type="int" value="0"/> + </properties> + </tile> + <tile id="35"> + <properties> + <property name="delay" type="int" value="100"/> + <property name="entity" value="player-top"/> + <property name="keyframe" type="int" value="1"/> + </properties> + </tile> + <tile id="44"> + <properties> + <property name="delay" type="int" value="100"/> + <property name="entity" value="player-bottom"/> + <property name="keyframe" type="int" value="0"/> + </properties> + </tile> + <tile id="45"> + <properties> + <property name="delay" type="int" value="100"/> + <property name="entity" value="player-bottom"/> + <property name="keyframe" type="int" value="1"/> + </properties> + </tile> </tileset> diff --git a/src/tile.rs b/src/tile.rs index 198be10..cb2aa83 100644 --- a/src/tile.rs +++ b/src/tile.rs @@ -67,11 +67,12 @@ impl Tile { pub fn update(&mut self) { if let Some(animations) = &self.animations { - let mut i = animations.iter().position(|a| a.1 == self.source).unwrap(); - if self.timer.elapsed().as_millis() > animations[i].0 as u128 { - i = if i == animations.len() - 1 { 0 } else { i + 1 }; - self.source = animations[i].1; - self.timer = Instant::now() + if let Some(mut i) = animations.iter().position(|a| a.1 == self.source) { + if self.timer.elapsed().as_millis() > animations[i].0 as u128 { + i = if i == animations.len() - 1 { 0 } else { i + 1 }; + self.source = animations[i].1; + self.timer = Instant::now() + } } } } |