From 9e0b822dfc71be6314e9d97ee3443e01a2a3762d Mon Sep 17 00:00:00 2001 From: "Timothy J. Warren" Date: Mon, 27 Jul 2020 12:09:55 -0400 Subject: [PATCH] Messing with maps --- resources/maps/00.txt | 11 +++++++++++ src/main.rs | 25 ++++++++++++++----------- src/map.rs | 10 +++++----- 3 files changed, 30 insertions(+), 16 deletions(-) create mode 100644 resources/maps/00.txt diff --git a/resources/maps/00.txt b/resources/maps/00.txt new file mode 100644 index 0000000..8a5f385 --- /dev/null +++ b/resources/maps/00.txt @@ -0,0 +1,11 @@ +N N N N X X X X X N N N N N N N N N N N N N +N N N N X . . . X N N N N N N N N N N N N N +N N N N X * . . X N N N N N N N N N N N N N +N N X X X . . * X X X N N N N N N N N N N N +N N X . . * . . * . X N N N N N N N N N N N +X X X . X . X X X . X N N N N N X X X X X X +X . . . X . X X X . X X X X X X X . . % % X +X . * . . * . . . . . . . . . . . . . % % X +X X X X X . X X X X . X @ X X X X . . % % X +N N N N X . . . . . . X X X N N X X X X X X +N N N N X X X X X X X X N N N N N N N N N N \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 81ba3a9..bd232ed 100644 --- a/src/main.rs +++ b/src/main.rs @@ -78,19 +78,20 @@ impl event::EventHandler for Game { pub fn initialize_level(world: &mut World) { const MAP: &str = " - N N N N W W W W W N N N N N N N N N N N N N - N N N N W . . . W N N N N N N N N N N N N N - N N N N W BB . . W N N N N N N N N N N N N N - N N W W W . . BB W W W N N N N N N N N N N N - N N W . . BB . . BB . W N N N N N N N N N N N - W W W . W . W W W . W N N N N N W W W W W W - W . . . W . W W W . W W W W W W W . . BS BS W - W . BB . . BB . . . . . . . . . . . . . BS BS W - W W W W W . W W W W . W P W W W W . . BS BS W - N N N N W . . . . . . W W W N N W W W W W W - N N N N W W W W W W W W N N N N N N N N N N + N N N N X X X X X N N N N N N N N N N N N N + N N N N X . . . X N N N N N N N N N N N N N + N N N N X * . . X N N N N N N N N N N N N N + N N X X X . . * X X X N N N N N N N N N N N + N N X . . * . . * . X N N N N N N N N N N N + X X X . X . X X X . X N N N N N X X X X X X + X . . . X . X X X . X X X X X X X . . % % X + X . * . . * . . . . . . . . . . . . . % % X + X X X X X . X X X X . X @ X X X X . . % % X + N N N N X . . . . . . X X X N N X X X X X X + N N N N X X X X X X X X N N N N N N N N N N "; + // @TODO: load map from file load_map(world, MAP.to_string()); } @@ -98,6 +99,8 @@ pub fn main() -> GameResult { let mut world = World::new(); register_components(&mut world); register_resources(&mut world); + + // @TODO multiple levels initialize_level(&mut world); // Create a game context and event loop diff --git a/src/map.rs b/src/map.rs index a62f2b0..cac5362 100644 --- a/src/map.rs +++ b/src/map.rs @@ -16,15 +16,15 @@ pub fn load_map(world: &mut World, map_string: String) { // Figure out which object to create match *column { "." => create_floor(world, position), - "W" => { + "X" => { create_floor(world, position); create_wall(world, position); } - "P" => { + "@" => { create_floor(world, position); create_player(world, position); } - "BB" => { + "*" => { create_floor(world, position); create_box(world, position, BoxColor::Blue); } @@ -32,7 +32,7 @@ pub fn load_map(world: &mut World, map_string: String) { create_floor(world, position); create_box(world, position, BoxColor::Red); } - "BS" => { + "%" => { create_floor(world, position); create_box_spot(world, position, BoxColor::Blue); } @@ -40,7 +40,7 @@ pub fn load_map(world: &mut World, map_string: String) { create_floor(world, position); create_box_spot(world, position, BoxColor::Red); } - "N" => (), + "N" | " " => (), c => panic!("unrecognized map item {}", c), } }