Add more difficulty
This commit is contained in:
14
src/map.rs
14
src/map.rs
@@ -10,6 +10,7 @@ use crate::rect::Rect;
|
||||
pub enum TileType {
|
||||
Wall,
|
||||
Floor,
|
||||
DownStairs,
|
||||
}
|
||||
|
||||
pub const MAP_WIDTH: usize = 80;
|
||||
@@ -27,6 +28,7 @@ pub struct Map {
|
||||
pub revealed_tiles: Vec<bool>,
|
||||
pub visible_tiles: Vec<bool>,
|
||||
pub blocked: Vec<bool>,
|
||||
pub depth: i32,
|
||||
|
||||
#[serde(skip_serializing)]
|
||||
#[serde(skip_deserializing)]
|
||||
@@ -85,7 +87,7 @@ impl Map {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new_map_rooms_and_corridors() -> Map {
|
||||
pub fn new_map_rooms_and_corridors(new_depth: i32) -> Map {
|
||||
let mut map = Map {
|
||||
tiles: vec![TileType::Wall; MAP_COUNT],
|
||||
rooms: Vec::new(),
|
||||
@@ -95,6 +97,7 @@ impl Map {
|
||||
visible_tiles: vec![false; MAP_COUNT],
|
||||
blocked: vec![false; MAP_COUNT],
|
||||
tile_content: vec![Vec::new(); MAP_COUNT],
|
||||
depth: new_depth,
|
||||
};
|
||||
|
||||
const MAX_ROOMS: i32 = 30;
|
||||
@@ -134,6 +137,10 @@ impl Map {
|
||||
}
|
||||
}
|
||||
|
||||
let stairs_position = map.rooms[map.rooms.len() - 1].center();
|
||||
let stairs_idx = map.xy_idx(stairs_position.0, stairs_position.1);
|
||||
map.tiles[stairs_idx] = TileType::DownStairs;
|
||||
|
||||
map
|
||||
}
|
||||
}
|
||||
@@ -211,6 +218,11 @@ pub fn draw_map(ecs: &World, ctx: &mut Rltk) {
|
||||
fg = RGB::from_f32(0., 1.0, 0.);
|
||||
glyph = rltk::to_cp437('#');
|
||||
}
|
||||
|
||||
TileType::DownStairs => {
|
||||
glyph = rltk::to_cp437('>');
|
||||
fg = RGB::from_f32(0., 1., 1.);
|
||||
}
|
||||
}
|
||||
if !map.visible_tiles[idx] {
|
||||
fg = fg.to_greyscale()
|
||||
|
Reference in New Issue
Block a user