Add chapter: 17
This commit is contained in:
14
src/map.rs
14
src/map.rs
@@ -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;
|
||||
|
Reference in New Issue
Block a user