summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/tile.rs11
1 files changed, 6 insertions, 5 deletions
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()
+ }
}
}
}