From 322224b3b84d6b4c701323b145c5842a5a0f859d Mon Sep 17 00:00:00 2001 From: Thomas Forgione Date: Sat, 30 Mar 2019 16:47:23 +0100 Subject: [PATCH] Don't need from_str --- src/engine/map/mod.rs | 26 -------------------------- 1 file changed, 26 deletions(-) diff --git a/src/engine/map/mod.rs b/src/engine/map/mod.rs index 6224dbf..cffd8c3 100644 --- a/src/engine/map/mod.rs +++ b/src/engine/map/mod.rs @@ -330,32 +330,6 @@ impl Map { Ok(deserialize_from(&mut reader).map_err(Error::Decoding)?) } - /// Creates a map from a txt file. - pub fn from_str(text: &str) -> Result { - let split = text.split('\n').collect::>(); - - // First two usize are the size of the map - let size = split[0] - .split_whitespace() - .map(|x| x.parse::().unwrap()) - .collect::>(); - - let mut tiles = Matrix::from_size(size[0], size[1], CollisionTile::empty()); - - for (row, line) in split.iter().skip(1).enumerate() { - for (col, tile) in line.split_whitespace().enumerate() { - let num = tile.parse::().unwrap(); - match num { - 0 => (), - 1 => tiles[(row, col)] = CollisionTile::full(), - _ => panic!("Expecting 0 or 1 in level files"), - } - } - } - - Ok(Map::from_collision_tiles(tiles)) - } - /// Creates a map from its tiles. pub fn from_collision_tiles(tiles: Matrix) -> Map { let rows = tiles.rows();