Implement start of Mushroom Forest entrance

This commit is contained in:
Timothy Warren 2022-01-28 12:28:42 -05:00
parent c1b72b22a1
commit eef254e2be
4 changed files with 60 additions and 4 deletions

View File

@ -15,6 +15,9 @@ pub const BLACK: RGB = new(0., 0., 0.);
/// RGB: (102, 102, 102)
pub const DARK_GRAY: RGB = new(0.4, 0.4, 0.4);
/// RGB: (128, 128, 128)
pub const MID_GRAY: RGB = new(0.5, 0.5, 0.5);
/// HEX: #999
/// RGB: (153, 153, 153)
pub const BOX_GRAY: RGB = new(0.6, 0.6, 0.6);
@ -70,9 +73,6 @@ pub const GREEN: RGB = new(0., 1., 0.);
/// RGB: (255, 0, 255)
pub const MAGENTA: RGB = new(1., 0., 1.);
/// RGB: (128, 128, 128)
pub const MID_GRAY: RGB = new(0.5, 0.5, 0.5);
/// RGB: (255, 165, 0)
pub const ORANGE: RGB = new(1., 0.647, 0.);

View File

@ -6,6 +6,14 @@ use crate::colors;
pub fn tile_glyph(idx: usize, map: &Map) -> (FontCharType, RGB, RGB) {
let (glyph, mut fg, mut bg) = match map.depth {
7 => {
let x = idx as i32 % map.width;
if x > map.width - 16 {
get_tile_glyph_default(idx, map)
} else {
get_mushroom_glyph(idx, map)
}
}
5 => {
let x = idx as i32 % map.width;
if x < map.width / 2 {
@ -74,7 +82,26 @@ fn get_forest_glyph(idx: usize, map: &Map) -> (FontCharType, RGB, RGB) {
(glyph, fg, bg)
}
fn get_tile_glyph_default(idx: usize, map: &Map) -> (rltk::FontCharType, RGB, RGB) {
fn get_mushroom_glyph(idx: usize, map: &Map) -> (FontCharType, RGB, RGB) {
let bg = colors::BLACK;
let (glyph, fg) = match map.tiles[idx] {
TileType::Wall => (to_cp437('♠'), colors::MAGENTA),
TileType::Bridge => (to_cp437('.'), colors::GREEN),
TileType::Road => (to_cp437('≡'), colors::CHOCOLATE),
TileType::Grass => (to_cp437('"'), colors::GREEN),
TileType::ShallowWater => (to_cp437('~'), colors::CYAN),
TileType::DeepWater => (to_cp437('~'), colors::BLUE),
TileType::Gravel => (to_cp437(';'), colors::MID_GRAY),
TileType::DownStairs => (to_cp437('>'), colors::CYAN),
TileType::UpStairs => (to_cp437('<'), colors::CYAN),
_ => (to_cp437('"'), colors::FOREST_GREEN),
};
(glyph, fg, bg)
}
fn get_tile_glyph_default(idx: usize, map: &Map) -> (FontCharType, RGB, RGB) {
let mut bg = colors::BLACK;
let (glyph, mut fg) = match map.tiles[idx] {

View File

@ -13,6 +13,7 @@ mod dwarf_fort;
mod forest;
mod limestone_cavern;
mod maze;
mod mushroom_forest;
mod prefab_builder;
mod room_based_spawner;
mod room_based_stairs;
@ -50,6 +51,7 @@ use limestone_cavern::{
limestone_cavern_builder, limestone_deep_cavern_builder, limestone_transition_builder,
};
use maze::MazeBuilder;
use mushroom_forest::*;
use prefab_builder::PrefabBuilder;
use room_based_spawner::RoomBasedSpawner;
use room_based_stairs::RoomBasedStairs;
@ -357,6 +359,7 @@ pub fn level_builder(
4 => limestone_deep_cavern_builder(new_depth, rng, width, height),
5 => limestone_transition_builder(new_depth, rng, width, height),
6 => dwarf_fort_builder(new_depth, rng, width, height),
7 => mushroom_entrance(new_depth, rng, width, height),
_ => random_builder(new_depth, rng, width, height),
}
}

View File

@ -0,0 +1,26 @@
use super::prefab_builder::prefab_sections::UNDERGROUND_FORT;
use super::{
AreaEndingPosition, AreaStartingPosition, BuilderChain, CellularAutomataBuilder,
CullUnreachable, PrefabBuilder, VoronoiSpawning, WaveformCollapseBuilder, XEnd, XStart, YEnd,
YStart,
};
pub fn mushroom_entrance(
new_depth: i32,
_rng: &mut ::rltk::RandomNumberGenerator,
width: i32,
height: i32,
) -> BuilderChain {
let mut chain = BuilderChain::new(new_depth, width, height, "Into the Mushroom Grove");
chain
.start_with(CellularAutomataBuilder::new())
.with(WaveformCollapseBuilder::new())
.with(AreaStartingPosition::new(XStart::Center, YStart::Center))
.with(CullUnreachable::new())
.with(AreaStartingPosition::new(XStart::Right, YStart::Center))
.with(AreaEndingPosition::new(XEnd::Left, YEnd::Center))
.with(VoronoiSpawning::new())
.with(PrefabBuilder::sectional(UNDERGROUND_FORT));
chain
}