diff options
author | tom barrett <spalf0@gmail.com> | 2019-07-04 03:51:15 -0500 |
---|---|---|
committer | tom barrett <spalf0@gmail.com> | 2019-07-04 03:51:15 -0500 |
commit | c9ce92e1830505269b631ba1fdd864a173bacf48 (patch) | |
tree | 0223704e95a04fd1d430876ac4a4d9a57e84a1ab /src/tileset.rs | |
parent | c04c59c7dd5ee6e3982a8ba45e42072b34f2be8a (diff) |
better naming
Diffstat (limited to 'src/tileset.rs')
-rw-r--r-- | src/tileset.rs | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/src/tileset.rs b/src/tileset.rs index 0595186..975398d 100644 --- a/src/tileset.rs +++ b/src/tileset.rs @@ -2,6 +2,7 @@ use ggez::filesystem::File; use ggez::graphics::Rect; use std::collections::HashMap; +use crate::animation::Frame; use crate::constants; use crate::property::Property; use crate::xmlelements::XMLElements; @@ -96,17 +97,23 @@ impl Tileset { } } - pub fn get_tile_by_entity_keyframe(&self, entity: &str, keyframe: usize) -> Rect { - *self - .tiles - .get( - &self - .properties - .iter() - .find(|p| p.entity == Some(entity.to_string()) && Some(keyframe) == p.keyframe) - .unwrap() - .tile_id, - ) + pub fn get_frame_by_entity_keyframe(&self, entity: &str, keyframe: usize) -> Frame { + let tile_id = &self + .properties + .iter() + .find(|p| p.entity == Some(entity.to_string()) && Some(keyframe) == p.keyframe) + .unwrap() + .tile_id; + + let delay = self + .properties + .iter() + .find(|p| p.tile_id == *tile_id && p.delay.is_some()) .unwrap() + .delay; + + let source = self.tiles.get(tile_id).unwrap(); + + Frame::new(*source, delay, 0.0) } } |