Add more difficulty

This commit is contained in:
2022-01-28 00:48:54 +01:00
parent e68fa87fc9
commit fb5b70ce3b
7 changed files with 254 additions and 59 deletions

View File

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