overmap, refactor offsets
This commit is contained in:
parent
9e294a1680
commit
746de971f0
14 changed files with 322 additions and 95 deletions
|
|
@ -8,7 +8,7 @@ pub use interval_spawning_system::try_spawn_interval;
|
|||
pub mod dungeon;
|
||||
pub use dungeon::{ level_transition, MasterDungeonMap };
|
||||
pub mod themes;
|
||||
use crate::data::visuals::MAX_COLOUR_OFFSET_PERCENT;
|
||||
use crate::data::visuals::MAX_COLOUR_OFFSET;
|
||||
|
||||
// FIXME: If the map size gets too small, entities stop being rendered starting from the right.
|
||||
// i.e. on a map size of 40*40, only entities to the left of the player are rendered.
|
||||
|
|
@ -16,6 +16,7 @@ use crate::data::visuals::MAX_COLOUR_OFFSET_PERCENT;
|
|||
|
||||
#[derive(Default, Serialize, Deserialize, Clone)]
|
||||
pub struct Map {
|
||||
pub overmap: bool,
|
||||
pub tiles: Vec<TileType>,
|
||||
pub width: i32,
|
||||
pub height: i32,
|
||||
|
|
@ -23,7 +24,7 @@ pub struct Map {
|
|||
pub visible_tiles: Vec<bool>,
|
||||
pub lit_tiles: Vec<bool>,
|
||||
pub telepath_tiles: Vec<bool>,
|
||||
pub colour_offset: Vec<(f32, f32, f32)>,
|
||||
pub colour_offset: Vec<(i32, i32, i32)>,
|
||||
pub additional_fg_offset: rltk::RGB,
|
||||
pub id: i32,
|
||||
pub name: String,
|
||||
|
|
@ -37,10 +38,11 @@ impl Map {
|
|||
(y as usize) * (self.width as usize) + (x as usize)
|
||||
}
|
||||
|
||||
pub fn new<S: ToString>(new_id: i32, width: i32, height: i32, difficulty: i32, name: S) -> Map {
|
||||
pub fn new<S: ToString>(overmap: bool, new_id: i32, width: i32, height: i32, difficulty: i32, name: S) -> Map {
|
||||
let map_tile_count = (width * height) as usize;
|
||||
crate::spatial::set_size(map_tile_count);
|
||||
let mut map = Map {
|
||||
overmap: overmap,
|
||||
tiles: vec![TileType::Wall; map_tile_count],
|
||||
width: width,
|
||||
height: height,
|
||||
|
|
@ -48,11 +50,11 @@ impl Map {
|
|||
visible_tiles: vec![false; map_tile_count],
|
||||
lit_tiles: vec![true; map_tile_count], // NYI: Light sources. Once those exist, we can set this to false.
|
||||
telepath_tiles: vec![false; map_tile_count],
|
||||
colour_offset: vec![(1.0, 1.0, 1.0); map_tile_count],
|
||||
colour_offset: vec![(0, 0, 0); map_tile_count],
|
||||
additional_fg_offset: rltk::RGB::from_u8(
|
||||
MAX_COLOUR_OFFSET_PERCENT as u8,
|
||||
MAX_COLOUR_OFFSET_PERCENT as u8,
|
||||
MAX_COLOUR_OFFSET_PERCENT as u8
|
||||
MAX_COLOUR_OFFSET as u8,
|
||||
MAX_COLOUR_OFFSET as u8,
|
||||
MAX_COLOUR_OFFSET as u8
|
||||
),
|
||||
id: new_id,
|
||||
name: name.to_string(),
|
||||
|
|
@ -61,16 +63,13 @@ impl Map {
|
|||
view_blocked: HashSet::new(),
|
||||
};
|
||||
|
||||
const TWICE_OFFSET: i32 = MAX_COLOUR_OFFSET_PERCENT * 2;
|
||||
const TWICE_OFFSET: i32 = MAX_COLOUR_OFFSET * 2;
|
||||
let mut rng = rltk::RandomNumberGenerator::new();
|
||||
|
||||
for idx in 0..map.colour_offset.len() {
|
||||
let red_roll: f32 =
|
||||
((rng.roll_dice(1, TWICE_OFFSET - 1) + 1 - MAX_COLOUR_OFFSET_PERCENT) as f32) / 100f32 + 1.0;
|
||||
let green_roll: f32 =
|
||||
((rng.roll_dice(1, TWICE_OFFSET - 1) + 1 - MAX_COLOUR_OFFSET_PERCENT) as f32) / 100f32 + 1.0;
|
||||
let blue_roll: f32 =
|
||||
((rng.roll_dice(1, TWICE_OFFSET - 1) + 1 - MAX_COLOUR_OFFSET_PERCENT) as f32) / 100f32 + 1.0;
|
||||
let red_roll: i32 = rng.roll_dice(1, TWICE_OFFSET) - MAX_COLOUR_OFFSET;
|
||||
let blue_roll: i32 = rng.roll_dice(1, TWICE_OFFSET) - MAX_COLOUR_OFFSET;
|
||||
let green_roll: i32 = rng.roll_dice(1, TWICE_OFFSET) - MAX_COLOUR_OFFSET;
|
||||
map.colour_offset[idx] = (red_roll, green_roll, blue_roll);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue