increases colour offset, and adds a config option for offset %

This commit is contained in:
Llywelwyn 2023-08-23 22:07:00 +01:00
parent ff344ccee4
commit 3c5f52faba
2 changed files with 14 additions and 6 deletions

View file

@ -3,6 +3,7 @@ pub const WITH_SCANLINES: bool = false; // Adds scanlines to the screen.
pub const WITH_SCREEN_BURN: bool = false; // Requires WITH_SCANLINES.
pub const WITH_DARKEN_BY_DISTANCE: bool = true; // If further away tiles should get darkened, instead of a harsh transition to non-visible.
pub const MAX_COLOUR_OFFSET_PERCENT: i32 = 30;
pub const WITH_SCANLINES_BRIGHTEN_AMOUNT: f32 = 0.1; // 0.0 = no brightening, 1.0 = full brightening.
pub const NON_VISIBLE_MULTIPLIER: f32 = 0.3; // 0.0 = black, 1.0 = full colour.
pub const NON_VISIBLE_MULTIPLIER_IF_SCANLINES: f32 = 0.8; // as above, but when using scanlines. should be higher.

View file

@ -8,6 +8,7 @@ pub use interval_spawning_system::try_spawn_interval;
pub mod dungeon;
pub use dungeon::{ level_transition, MasterDungeonMap };
pub mod themes;
use crate::config::visuals::MAX_COLOUR_OFFSET_PERCENT;
// 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.
@ -48,7 +49,11 @@ impl Map {
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],
additional_fg_offset: rltk::RGB::from_u8(OFFSET_PERCENT as u8, OFFSET_PERCENT as u8, OFFSET_PERCENT as u8),
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
),
id: new_id,
name: name.to_string(),
difficulty: difficulty,
@ -56,14 +61,16 @@ impl Map {
view_blocked: HashSet::new(),
};
const OFFSET_PERCENT: i32 = 20;
const TWICE_OFFSET: i32 = OFFSET_PERCENT * 2;
const TWICE_OFFSET: i32 = MAX_COLOUR_OFFSET_PERCENT * 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 - OFFSET_PERCENT) as f32) / 100f32 + 1.0;
let green_roll: f32 = ((rng.roll_dice(1, TWICE_OFFSET - 1) + 1 - OFFSET_PERCENT) as f32) / 100f32 + 1.0;
let blue_roll: f32 = ((rng.roll_dice(1, TWICE_OFFSET - 1) + 1 - OFFSET_PERCENT) as f32) / 100f32 + 1.0;
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;
map.colour_offset[idx] = (red_roll, green_roll, blue_roll);
}