forked from tutorials/rust-sokoban
Messing with maps
This commit is contained in:
parent
e57be66c5e
commit
9e0b822dfc
11
resources/maps/00.txt
Normal file
11
resources/maps/00.txt
Normal 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
|
25
src/main.rs
25
src/main.rs
@ -78,19 +78,20 @@ impl event::EventHandler for Game {
|
|||||||
|
|
||||||
pub fn initialize_level(world: &mut World) {
|
pub fn initialize_level(world: &mut World) {
|
||||||
const MAP: &str = "
|
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 X X X X X 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 X . . . X 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 N N X * . . X 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 X X X . . * X X X 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
|
N N X . . * . . * . X 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
|
X X X . X . X X X . X N N N N N X X X X X X
|
||||||
W . . . W . W W W . W W W W W W W . . BS BS W
|
X . . . X . X X X . X X X X X X X . . % % X
|
||||||
W . BB . . BB . . . . . . . . . . . . . BS BS W
|
X . * . . * . . . . . . . . . . . . . % % X
|
||||||
W W W W W . W W W W . W P W W W W . . BS BS W
|
X X X X X . X X X X . X @ X X X X . . % % X
|
||||||
N N N N W . . . . . . W W W N N W W W W W W
|
N N N N X . . . . . . X X X N N X X X X X X
|
||||||
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 X X X N N N N N N N N N N
|
||||||
";
|
";
|
||||||
|
|
||||||
|
// @TODO: load map from file
|
||||||
load_map(world, MAP.to_string());
|
load_map(world, MAP.to_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,6 +99,8 @@ pub fn main() -> GameResult {
|
|||||||
let mut world = World::new();
|
let mut world = World::new();
|
||||||
register_components(&mut world);
|
register_components(&mut world);
|
||||||
register_resources(&mut world);
|
register_resources(&mut world);
|
||||||
|
|
||||||
|
// @TODO multiple levels
|
||||||
initialize_level(&mut world);
|
initialize_level(&mut world);
|
||||||
|
|
||||||
// Create a game context and event loop
|
// Create a game context and event loop
|
||||||
|
10
src/map.rs
10
src/map.rs
@ -16,15 +16,15 @@ pub fn load_map(world: &mut World, map_string: String) {
|
|||||||
// Figure out which object to create
|
// Figure out which object to create
|
||||||
match *column {
|
match *column {
|
||||||
"." => create_floor(world, position),
|
"." => create_floor(world, position),
|
||||||
"W" => {
|
"X" => {
|
||||||
create_floor(world, position);
|
create_floor(world, position);
|
||||||
create_wall(world, position);
|
create_wall(world, position);
|
||||||
}
|
}
|
||||||
"P" => {
|
"@" => {
|
||||||
create_floor(world, position);
|
create_floor(world, position);
|
||||||
create_player(world, position);
|
create_player(world, position);
|
||||||
}
|
}
|
||||||
"BB" => {
|
"*" => {
|
||||||
create_floor(world, position);
|
create_floor(world, position);
|
||||||
create_box(world, position, BoxColor::Blue);
|
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_floor(world, position);
|
||||||
create_box(world, position, BoxColor::Red);
|
create_box(world, position, BoxColor::Red);
|
||||||
}
|
}
|
||||||
"BS" => {
|
"%" => {
|
||||||
create_floor(world, position);
|
create_floor(world, position);
|
||||||
create_box_spot(world, position, BoxColor::Blue);
|
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_floor(world, position);
|
||||||
create_box_spot(world, position, BoxColor::Red);
|
create_box_spot(world, position, BoxColor::Red);
|
||||||
}
|
}
|
||||||
"N" => (),
|
"N" | " " => (),
|
||||||
c => panic!("unrecognized map item {}", c),
|
c => panic!("unrecognized map item {}", c),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user