Add chapter: 17

This commit is contained in:
2022-01-28 20:20:04 +01:00
parent 743bf7abde
commit 0e2c91dd12
3 changed files with 22 additions and 7 deletions

View File

@@ -1,4 +1,5 @@
use std::cmp::{max, min};
use std::collections::HashSet;
use rltk::{Algorithm2D, BaseMap, FontCharType, Point, RandomNumberGenerator, RGB, Rltk};
use serde::{Deserialize, Serialize};
@@ -28,6 +29,7 @@ pub struct Map {
pub visible_tiles: Vec<bool>,
pub blocked: Vec<bool>,
pub depth: i32,
pub bloodstains: HashSet<usize>,
#[serde(skip_serializing)]
#[serde(skip_deserializing)]
@@ -97,6 +99,7 @@ impl Map {
blocked: vec![false; MAP_COUNT],
tile_content: vec![Vec::new(); MAP_COUNT],
depth: new_depth,
bloodstains: HashSet::new(),
};
const MAX_ROOMS: i32 = 30;
@@ -207,6 +210,7 @@ pub fn draw_map(ecs: &World, ctx: &mut Rltk) {
if map.revealed_tiles[idx] {
let glyph;
let mut fg;
let mut bg = RGB::from_f32(0., 0., 0.);
match tile {
TileType::Floor => {
fg = RGB::from_f32(0.0, 0.5, 0.5);
@@ -223,10 +227,14 @@ pub fn draw_map(ecs: &World, ctx: &mut Rltk) {
fg = RGB::from_f32(0., 1., 1.);
}
}
if !map.visible_tiles[idx] {
fg = fg.to_greyscale()
if map.bloodstains.contains(&idx) {
bg = RGB::from_f32(0.71, 0., 0.);
}
ctx.set(x, y, fg, RGB::from_f32(0., 0., 0.), glyph);
if !map.visible_tiles[idx] {
fg = fg.to_greyscale();
bg = RGB::from_f32(0., 0., 0.);
}
ctx.set(x, y, fg, bg, glyph);
}
x += 1;