summaryrefslogtreecommitdiff
path: root/src/map.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/map.rs
parent503361ce70615d7c4b66bd7e49d56c61259dab32 (diff)
animation now always works, added player spawn
Diffstat (limited to 'src/map.rs')
-rw-r--r--src/map.rs13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/map.rs b/src/map.rs
index 8ef6f4e..124125a 100644
--- a/src/map.rs
+++ b/src/map.rs
@@ -61,7 +61,7 @@ impl Map {
})
.collect();
- let spawns = Map::get_spawn_points(&layers, tileset.get_spawn_tiles());
+ let spawns = Map::find_spawn_points(&layers, tileset.get_spawn_tiles());
Map {
layers,
@@ -70,7 +70,7 @@ impl Map {
}
}
- fn get_spawn_points(
+ fn find_spawn_points(
layers: &[Layer],
spawn_tiles: HashMap<usize, Tile>,
) -> Vec<(String, Point2<f32>)> {
@@ -90,8 +90,13 @@ impl Map {
spawn_points
}
- pub fn get_spawns(&self) -> Vec<(String, Point2<f32>)> {
- self.spawns.clone()
+ pub fn get_spawn_points(&self, name: &str) -> Vec<Point2<f32>> {
+ self.spawns
+ .clone()
+ .into_iter()
+ .filter(|s| s.0 == name)
+ .map(|s| s.1)
+ .collect()
}
pub fn get_dimensions(&self) -> (f32, f32) {