Messing with maps

This commit is contained in:
Timothy Warren 2020-07-27 12:09:55 -04:00
parent e57be66c5e
commit 9e0b822dfc
3 changed files with 30 additions and 16 deletions

11
resources/maps/00.txt Normal file
View File

@ -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

View File

@ -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

View File

@ -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),
}
}