Make color usage consistent through the use of constants
This commit is contained in:
parent
a3fdba4fe5
commit
3cad614e78
@ -1,8 +1,8 @@
|
|||||||
use ::rltk::{Point, Rltk, RGB};
|
use ::rltk::{Point, Rltk};
|
||||||
use ::specs::prelude::*;
|
use ::specs::prelude::*;
|
||||||
|
|
||||||
use crate::map::tile_glyph;
|
use crate::map::tile_glyph;
|
||||||
use crate::{Hidden, Map, Position, Renderable};
|
use crate::{colors, Hidden, Map, Position, Renderable};
|
||||||
|
|
||||||
const SHOW_BOUNDARIES: bool = false;
|
const SHOW_BOUNDARIES: bool = false;
|
||||||
|
|
||||||
@ -42,13 +42,7 @@ pub fn render_camera(ecs: &World, ctx: &mut Rltk) {
|
|||||||
ctx.set(x, y, fg, bg, glyph);
|
ctx.set(x, y, fg, bg, glyph);
|
||||||
}
|
}
|
||||||
} else if SHOW_BOUNDARIES {
|
} else if SHOW_BOUNDARIES {
|
||||||
ctx.set(
|
ctx.set(x, y, colors::GRAY, colors::BLACK, rltk::to_cp437('·'));
|
||||||
x,
|
|
||||||
y,
|
|
||||||
RGB::named(rltk::GRAY),
|
|
||||||
RGB::named(rltk::BLACK),
|
|
||||||
rltk::to_cp437('·'),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
x += 1;
|
x += 1;
|
||||||
}
|
}
|
||||||
@ -114,13 +108,7 @@ pub fn render_debug_map(map: &Map, ctx: &mut Rltk) {
|
|||||||
ctx.set(x, y, fg, bg, glyph);
|
ctx.set(x, y, fg, bg, glyph);
|
||||||
}
|
}
|
||||||
} else if SHOW_BOUNDARIES {
|
} else if SHOW_BOUNDARIES {
|
||||||
ctx.set(
|
ctx.set(x, y, colors::GRAY, colors::BLACK, rltk::to_cp437('·'));
|
||||||
x,
|
|
||||||
y,
|
|
||||||
RGB::named(rltk::GRAY),
|
|
||||||
RGB::named(rltk::BLACK),
|
|
||||||
rltk::to_cp437('·'),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
x += 1;
|
x += 1;
|
||||||
}
|
}
|
||||||
|
94
src/colors.rs
Normal file
94
src/colors.rs
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
//! Color constants to replace more verbose methods of defining colors in the game.
|
||||||
|
//! These constants replace the `::rltk::RGB` constructor functions
|
||||||
|
use ::rltk::RGB;
|
||||||
|
|
||||||
|
const fn new(r: f32, g: f32, b: f32) -> RGB {
|
||||||
|
RGB { r, g, b }
|
||||||
|
}
|
||||||
|
|
||||||
|
//Grays
|
||||||
|
|
||||||
|
/// HEX: #000
|
||||||
|
/// RGB: (0, 0, 0)
|
||||||
|
pub const BLACK: RGB = new(0., 0., 0.);
|
||||||
|
|
||||||
|
/// RGB: (102, 102, 102)
|
||||||
|
pub const DARK_GRAY: RGB = new(0.4, 0.4, 0.4);
|
||||||
|
|
||||||
|
/// HEX: #999
|
||||||
|
/// RGB: (153, 153, 153)
|
||||||
|
pub const BOX_GRAY: RGB = new(0.6, 0.6, 0.6);
|
||||||
|
|
||||||
|
/// RGB: (190, 190, 190)
|
||||||
|
pub const GRAY: RGB = new(0.745, 0.745, 0.745);
|
||||||
|
|
||||||
|
/// HEX: #CCC
|
||||||
|
/// RGB: (204, 204, 204)
|
||||||
|
pub const ATTR_GRAY: RGB = new(0.8, 0.8, 0.8);
|
||||||
|
|
||||||
|
/// Hex: #DDD
|
||||||
|
/// RGB: (221, 221, 221)
|
||||||
|
pub const LIGHT_GRAY: RGB = new(0.86667, 0.86667, 0.86667);
|
||||||
|
|
||||||
|
/// Hex: #FFF
|
||||||
|
/// RGB: (255, 255, 255)
|
||||||
|
pub const WHITE: RGB = new(1., 1., 1.);
|
||||||
|
|
||||||
|
// Non-grays
|
||||||
|
|
||||||
|
/// RGB: (191, 0, 0)
|
||||||
|
pub const BLOOD: RGB = new(0.75, 0., 0.);
|
||||||
|
|
||||||
|
/// HEX: #00F
|
||||||
|
/// RGB: (0, 0, 255)
|
||||||
|
pub const BLUE: RGB = new(0., 0., 1.);
|
||||||
|
|
||||||
|
/// RGB: (210, 105, 30)
|
||||||
|
pub const CHOCOLATE: RGB = new(0.83253, 0.41176, 0.11765);
|
||||||
|
|
||||||
|
/// HEX: #0FF
|
||||||
|
/// RGB: (0, 255, 255)
|
||||||
|
pub const CYAN: RGB = new(0., 1., 1.);
|
||||||
|
|
||||||
|
/// RGB: (0, 128, 128)
|
||||||
|
pub const DEFAULT_FLOOR: RGB = new(0., 0.5, 0.5);
|
||||||
|
|
||||||
|
/// RGB: (51, 51, 255)
|
||||||
|
pub const DEEP_WATER: RGB = new(0.2, 0.2, 1.0);
|
||||||
|
|
||||||
|
/// RGB: (0, 153, 0)
|
||||||
|
pub const FOREST_GREEN: RGB = new(0., 0.6, 0.);
|
||||||
|
|
||||||
|
/// RGB: (255, 215, 0)
|
||||||
|
pub const GOLD: RGB = new(1., 0.84314, 0.);
|
||||||
|
|
||||||
|
/// HEX: #0F0
|
||||||
|
/// RGB: (0, 255, 0)
|
||||||
|
pub const GREEN: RGB = new(0., 1., 0.);
|
||||||
|
|
||||||
|
/// Hex: #F0F
|
||||||
|
/// 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: (0, 0, 128)
|
||||||
|
pub const NAVY_BLUE: RGB = new(0., 0., 0.50196);
|
||||||
|
|
||||||
|
/// RGB: (255, 165, 0)
|
||||||
|
pub const ORANGE: RGB = new(1., 0.647, 0.);
|
||||||
|
|
||||||
|
/// Hex: #F00
|
||||||
|
/// RGB: (255, 0, 0)
|
||||||
|
pub const RED: RGB = new(1., 0., 0.);
|
||||||
|
|
||||||
|
/// RGB: (255, 255, 128)
|
||||||
|
pub const TORCH_LIGHT: RGB = new(1., 1., 0.5);
|
||||||
|
|
||||||
|
/// RGB: (245, 222, 179)
|
||||||
|
pub const WHEAT: RGB = new(0.96078, 0.87059, 0.70196);
|
||||||
|
|
||||||
|
/// Hex: #FF0
|
||||||
|
/// RGB: (255, 255, 0)
|
||||||
|
pub const YELLOW: RGB = new(1., 1., 0.);
|
@ -1,6 +1,5 @@
|
|||||||
use ::rltk::{Point, RandomNumberGenerator};
|
use ::rltk::{Point, RandomNumberGenerator};
|
||||||
use ::specs::prelude::*;
|
use ::specs::prelude::*;
|
||||||
use rltk::RGB;
|
|
||||||
|
|
||||||
use crate::components::{
|
use crate::components::{
|
||||||
Attributes, Equipped, InBackpack, LootTable, Name, Player, Pools, Position, SufferDamage,
|
Attributes, Equipped, InBackpack, LootTable, Name, Player, Pools, Position, SufferDamage,
|
||||||
@ -9,7 +8,7 @@ use crate::game_log::GameLog;
|
|||||||
use crate::gamesystem::{mana_at_level, player_hp_at_level};
|
use crate::gamesystem::{mana_at_level, player_hp_at_level};
|
||||||
use crate::particle_system::ParticleBuilder;
|
use crate::particle_system::ParticleBuilder;
|
||||||
use crate::raws::{self, SpawnType, RAWS};
|
use crate::raws::{self, SpawnType, RAWS};
|
||||||
use crate::{spatial, Map, RunState};
|
use crate::{colors, spatial, Map, RunState};
|
||||||
|
|
||||||
pub struct DamageSystem {}
|
pub struct DamageSystem {}
|
||||||
|
|
||||||
@ -93,8 +92,8 @@ impl<'a> System<'a> for DamageSystem {
|
|||||||
particles.request(
|
particles.request(
|
||||||
player_pos.x,
|
player_pos.x,
|
||||||
player_pos.y - 1,
|
player_pos.y - 1,
|
||||||
RGB::named(rltk::GOLD),
|
colors::GOLD,
|
||||||
RGB::named(rltk::BLACK),
|
colors::BLACK,
|
||||||
rltk::to_cp437('░'),
|
rltk::to_cp437('░'),
|
||||||
400.0,
|
400.0,
|
||||||
);
|
);
|
||||||
|
497
src/gui.rs
497
src/gui.rs
@ -9,7 +9,7 @@ use crate::components::{
|
|||||||
};
|
};
|
||||||
use crate::game_log::GameLog;
|
use crate::game_log::GameLog;
|
||||||
use crate::rex_assets::RexAssets;
|
use crate::rex_assets::RexAssets;
|
||||||
use crate::{camera, Equipped, Hidden, Map, RunState, State, VendorMode};
|
use crate::{camera, colors, Equipped, Hidden, Map, RunState, State, VendorMode};
|
||||||
|
|
||||||
pub fn draw_hollow_box(
|
pub fn draw_hollow_box(
|
||||||
console: &mut Rltk,
|
console: &mut Rltk,
|
||||||
@ -39,35 +39,32 @@ pub fn draw_hollow_box(
|
|||||||
|
|
||||||
pub fn draw_ui(ecs: &World, ctx: &mut Rltk) {
|
pub fn draw_ui(ecs: &World, ctx: &mut Rltk) {
|
||||||
use rltk::to_cp437;
|
use rltk::to_cp437;
|
||||||
let box_gray: RGB = RGB::from_hex("#999999").expect("Ooops");
|
|
||||||
let black = RGB::named(rltk::BLACK);
|
|
||||||
let white = RGB::named(rltk::WHITE);
|
|
||||||
|
|
||||||
draw_hollow_box(ctx, 0, 0, 79, 59, box_gray, black); // Overall box
|
draw_hollow_box(ctx, 0, 0, 79, 59, colors::BOX_GRAY, colors::BLACK); // Overall box
|
||||||
draw_hollow_box(ctx, 0, 0, 49, 45, box_gray, black); // Map box
|
draw_hollow_box(ctx, 0, 0, 49, 45, colors::BOX_GRAY, colors::BLACK); // Map box
|
||||||
draw_hollow_box(ctx, 0, 45, 79, 14, box_gray, black); // Log box
|
draw_hollow_box(ctx, 0, 45, 79, 14, colors::BOX_GRAY, colors::BLACK); // Log box
|
||||||
draw_hollow_box(ctx, 49, 0, 30, 8, box_gray, black); // Top-right panel
|
draw_hollow_box(ctx, 49, 0, 30, 8, colors::BOX_GRAY, colors::BLACK); // Top-right panel
|
||||||
|
|
||||||
ctx.set(0, 45, box_gray, black, to_cp437('├'));
|
ctx.set(0, 45, colors::BOX_GRAY, colors::BLACK, to_cp437('├'));
|
||||||
ctx.set(49, 8, box_gray, black, to_cp437('├'));
|
ctx.set(49, 8, colors::BOX_GRAY, colors::BLACK, to_cp437('├'));
|
||||||
ctx.set(49, 0, box_gray, black, to_cp437('┬'));
|
ctx.set(49, 0, colors::BOX_GRAY, colors::BLACK, to_cp437('┬'));
|
||||||
ctx.set(49, 45, box_gray, black, to_cp437('┴'));
|
ctx.set(49, 45, colors::BOX_GRAY, colors::BLACK, to_cp437('┴'));
|
||||||
ctx.set(79, 8, box_gray, black, to_cp437('┤'));
|
ctx.set(79, 8, colors::BOX_GRAY, colors::BLACK, to_cp437('┤'));
|
||||||
ctx.set(79, 45, box_gray, black, to_cp437('┤'));
|
ctx.set(79, 45, colors::BOX_GRAY, colors::BLACK, to_cp437('┤'));
|
||||||
|
|
||||||
// Draw the town name
|
// Draw the town name
|
||||||
let map = ecs.fetch::<Map>();
|
let map = ecs.fetch::<Map>();
|
||||||
let name_length = map.name.len() + 2;
|
let name_length = map.name.len() + 2;
|
||||||
let x_pos = (22 - (name_length / 2)) as i32;
|
let x_pos = (22 - (name_length / 2)) as i32;
|
||||||
ctx.set(x_pos, 0, box_gray, black, to_cp437('┤'));
|
ctx.set(x_pos, 0, colors::BOX_GRAY, colors::BLACK, to_cp437('┤'));
|
||||||
ctx.set(
|
ctx.set(
|
||||||
x_pos + name_length as i32,
|
x_pos + name_length as i32,
|
||||||
0,
|
0,
|
||||||
box_gray,
|
colors::BOX_GRAY,
|
||||||
black,
|
colors::BLACK,
|
||||||
to_cp437('├'),
|
to_cp437('├'),
|
||||||
);
|
);
|
||||||
ctx.print_color(x_pos + 1, 0, white, black, &map.name);
|
ctx.print_color(x_pos + 1, 0, colors::WHITE, colors::BLACK, &map.name);
|
||||||
std::mem::drop(map);
|
std::mem::drop(map);
|
||||||
|
|
||||||
// Draw stats
|
// Draw stats
|
||||||
@ -83,17 +80,17 @@ pub fn draw_ui(ecs: &World, ctx: &mut Rltk) {
|
|||||||
player_pools.mana.current, player_pools.mana.max
|
player_pools.mana.current, player_pools.mana.max
|
||||||
);
|
);
|
||||||
let xp = format!("Level: {}", player_pools.level);
|
let xp = format!("Level: {}", player_pools.level);
|
||||||
ctx.print_color(50, 1, white, black, &health);
|
ctx.print_color(50, 1, colors::WHITE, colors::BLACK, &health);
|
||||||
ctx.print_color(50, 2, white, black, &mana);
|
ctx.print_color(50, 2, colors::WHITE, colors::BLACK, &mana);
|
||||||
ctx.print_color(50, 3, white, black, &xp);
|
ctx.print_color(50, 3, colors::WHITE, colors::BLACK, &xp);
|
||||||
ctx.draw_bar_horizontal(
|
ctx.draw_bar_horizontal(
|
||||||
64,
|
64,
|
||||||
1,
|
1,
|
||||||
14,
|
14,
|
||||||
player_pools.hit_points.current,
|
player_pools.hit_points.current,
|
||||||
player_pools.hit_points.max,
|
player_pools.hit_points.max,
|
||||||
RGB::named(rltk::RED),
|
colors::RED,
|
||||||
RGB::named(rltk::BLACK),
|
colors::BLACK,
|
||||||
);
|
);
|
||||||
ctx.draw_bar_horizontal(
|
ctx.draw_bar_horizontal(
|
||||||
64,
|
64,
|
||||||
@ -101,8 +98,8 @@ pub fn draw_ui(ecs: &World, ctx: &mut Rltk) {
|
|||||||
14,
|
14,
|
||||||
player_pools.mana.current,
|
player_pools.mana.current,
|
||||||
player_pools.mana.max,
|
player_pools.mana.max,
|
||||||
RGB::named(rltk::BLUE),
|
colors::BLUE,
|
||||||
RGB::named(rltk::BLACK),
|
colors::BLACK,
|
||||||
);
|
);
|
||||||
let xp_level_start = (player_pools.level - 1) * 1000;
|
let xp_level_start = (player_pools.level - 1) * 1000;
|
||||||
ctx.draw_bar_horizontal(
|
ctx.draw_bar_horizontal(
|
||||||
@ -111,8 +108,8 @@ pub fn draw_ui(ecs: &World, ctx: &mut Rltk) {
|
|||||||
14,
|
14,
|
||||||
player_pools.xp - xp_level_start,
|
player_pools.xp - xp_level_start,
|
||||||
1000,
|
1000,
|
||||||
RGB::named(rltk::GOLD),
|
colors::GOLD,
|
||||||
black,
|
colors::BLACK,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Attributes
|
// Attributes
|
||||||
@ -127,8 +124,8 @@ pub fn draw_ui(ecs: &World, ctx: &mut Rltk) {
|
|||||||
ctx.print_color(
|
ctx.print_color(
|
||||||
50,
|
50,
|
||||||
9,
|
9,
|
||||||
white,
|
colors::WHITE,
|
||||||
black,
|
colors::BLACK,
|
||||||
&format!(
|
&format!(
|
||||||
"{:.0} lbs ({} lbs max)",
|
"{:.0} lbs ({} lbs max)",
|
||||||
player_pools.total_weight,
|
player_pools.total_weight,
|
||||||
@ -138,8 +135,8 @@ pub fn draw_ui(ecs: &World, ctx: &mut Rltk) {
|
|||||||
ctx.print_color(
|
ctx.print_color(
|
||||||
50,
|
50,
|
||||||
10,
|
10,
|
||||||
white,
|
colors::WHITE,
|
||||||
black,
|
colors::BLACK,
|
||||||
&format!(
|
&format!(
|
||||||
"Initiative Penalty: {:.0}",
|
"Initiative Penalty: {:.0}",
|
||||||
player_pools.total_initiative_penalty
|
player_pools.total_initiative_penalty
|
||||||
@ -148,8 +145,8 @@ pub fn draw_ui(ecs: &World, ctx: &mut Rltk) {
|
|||||||
ctx.print_color(
|
ctx.print_color(
|
||||||
50,
|
50,
|
||||||
11,
|
11,
|
||||||
RGB::named(rltk::GOLD),
|
colors::GOLD,
|
||||||
black,
|
colors::BLACK,
|
||||||
&format!("Gold: {:.1}", player_pools.gold),
|
&format!("Gold: {:.1}", player_pools.gold),
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -159,22 +156,20 @@ pub fn draw_ui(ecs: &World, ctx: &mut Rltk) {
|
|||||||
let name = ecs.read_storage::<Name>();
|
let name = ecs.read_storage::<Name>();
|
||||||
for (equipped_by, item_name) in (&equipped, &name).join() {
|
for (equipped_by, item_name) in (&equipped, &name).join() {
|
||||||
if equipped_by.owner == *player_entity {
|
if equipped_by.owner == *player_entity {
|
||||||
ctx.print_color(50, y, white, black, &item_name.name);
|
ctx.print_color(50, y, colors::WHITE, colors::BLACK, &item_name.name);
|
||||||
y += 1;
|
y += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Consumables
|
// Consumables
|
||||||
y += 1;
|
y += 1;
|
||||||
let green = RGB::from_f32(0.0, 1.0, 0.0);
|
|
||||||
let yellow = RGB::named(rltk::YELLOW);
|
|
||||||
let consumables = ecs.read_storage::<Consumable>();
|
let consumables = ecs.read_storage::<Consumable>();
|
||||||
let backpack = ecs.read_storage::<InBackpack>();
|
let backpack = ecs.read_storage::<InBackpack>();
|
||||||
let mut index = 1;
|
let mut index = 1;
|
||||||
for (carried_by, _consumable, item_name) in (&backpack, &consumables, &name).join() {
|
for (carried_by, _consumable, item_name) in (&backpack, &consumables, &name).join() {
|
||||||
if carried_by.owner == *player_entity && index < 10 {
|
if carried_by.owner == *player_entity && index < 10 {
|
||||||
ctx.print_color(50, y, yellow, black, &format!("↑{}", index));
|
ctx.print_color(50, y, colors::YELLOW, colors::BLACK, &format!("↑{}", index));
|
||||||
ctx.print_color(53, y, green, black, &item_name.name);
|
ctx.print_color(53, y, colors::GREEN, colors::BLACK, &item_name.name);
|
||||||
y += 1;
|
y += 1;
|
||||||
index += 1;
|
index += 1;
|
||||||
}
|
}
|
||||||
@ -184,10 +179,10 @@ pub fn draw_ui(ecs: &World, ctx: &mut Rltk) {
|
|||||||
let hunger = ecs.read_storage::<HungerClock>();
|
let hunger = ecs.read_storage::<HungerClock>();
|
||||||
let hc = hunger.get(*player_entity).unwrap();
|
let hc = hunger.get(*player_entity).unwrap();
|
||||||
match hc.state {
|
match hc.state {
|
||||||
HungerState::WellFed => ctx.print_color(50, 44, RGB::named(rltk::GREEN), black, "Well Fed"),
|
HungerState::WellFed => ctx.print_color(50, 44, colors::GREEN, colors::BLACK, "Well Fed"),
|
||||||
HungerState::Normal => {}
|
HungerState::Normal => {}
|
||||||
HungerState::Hungry => ctx.print_color(50, 44, RGB::named(rltk::ORANGE), black, "Hungry"),
|
HungerState::Hungry => ctx.print_color(50, 44, colors::ORANGE, colors::BLACK, "Hungry"),
|
||||||
HungerState::Starving => ctx.print_color(50, 44, RGB::named(rltk::RED), black, "Starving"),
|
HungerState::Starving => ctx.print_color(50, 44, colors::RED, colors::BLACK, "Starving"),
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw the log
|
// Draw the log
|
||||||
@ -204,27 +199,25 @@ pub fn draw_ui(ecs: &World, ctx: &mut Rltk) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn draw_attribute(name: &str, attribute: &Attribute, y: i32, ctx: &mut Rltk) {
|
fn draw_attribute(name: &str, attribute: &Attribute, y: i32, ctx: &mut Rltk) {
|
||||||
let black = RGB::named(rltk::BLACK);
|
ctx.print_color(50, y, colors::ATTR_GRAY, colors::BLACK, name);
|
||||||
let attr_gray = RGB::from_hex("#CCCCCC").expect("Oops");
|
|
||||||
ctx.print_color(50, y, attr_gray, black, name);
|
|
||||||
|
|
||||||
let color = match attribute.modifiers.cmp(&0) {
|
let color = match attribute.modifiers.cmp(&0) {
|
||||||
Ordering::Less => RGB::from_f32(1.0, 0.0, 0.0),
|
Ordering::Less => colors::RED,
|
||||||
Ordering::Equal => RGB::named(rltk::WHITE),
|
Ordering::Equal => colors::WHITE,
|
||||||
Ordering::Greater => RGB::from_f32(0.0, 1.0, 0.0),
|
Ordering::Greater => colors::GREEN,
|
||||||
};
|
};
|
||||||
|
|
||||||
ctx.print_color(
|
ctx.print_color(
|
||||||
67,
|
67,
|
||||||
y,
|
y,
|
||||||
color,
|
color,
|
||||||
black,
|
colors::BLACK,
|
||||||
&format!("{}", attribute.base + attribute.modifiers),
|
&format!("{}", attribute.base + attribute.modifiers),
|
||||||
);
|
);
|
||||||
ctx.print_color(73, y, color, black, &format!("{}", attribute.bonus));
|
ctx.print_color(73, y, color, colors::BLACK, &format!("{}", attribute.bonus));
|
||||||
|
|
||||||
if attribute.bonus > 0 {
|
if attribute.bonus > 0 {
|
||||||
ctx.set(72, y, color, black, rltk::to_cp437('+'));
|
ctx.set(72, y, color, colors::BLACK, rltk::to_cp437('+'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -257,16 +250,22 @@ impl Tooltip {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn render(&self, ctx: &mut Rltk, x: i32, y: i32) {
|
fn render(&self, ctx: &mut Rltk, x: i32, y: i32) {
|
||||||
let box_gray = RGB::from_hex("#999999").expect("Oops");
|
ctx.draw_box(
|
||||||
let light_gray = RGB::from_hex("#DDDDDD").expect("Oops");
|
x,
|
||||||
let white = RGB::named(rltk::WHITE);
|
y,
|
||||||
let black = RGB::named(rltk::BLACK);
|
self.width() - 1,
|
||||||
|
self.height() - 1,
|
||||||
ctx.draw_box(x, y, self.width() - 1, self.height() - 1, white, box_gray);
|
colors::WHITE,
|
||||||
|
colors::BOX_GRAY,
|
||||||
|
);
|
||||||
|
|
||||||
for (i, s) in self.lines.iter().enumerate() {
|
for (i, s) in self.lines.iter().enumerate() {
|
||||||
let col = if i == 0 { white } else { light_gray };
|
let col = if i == 0 {
|
||||||
ctx.print_color(x + 1, y + i as i32 + 1, col, black, &s);
|
colors::WHITE
|
||||||
|
} else {
|
||||||
|
colors::LIGHT_GRAY
|
||||||
|
};
|
||||||
|
ctx.print_color(x + 1, y + i as i32 + 1, col, colors::BLACK, &s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -352,9 +351,6 @@ fn draw_tooltips(ecs: &World, ctx: &mut Rltk) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let box_gray = RGB::from_hex("#999999").expect("Oops");
|
|
||||||
let white = RGB::named(rltk::WHITE);
|
|
||||||
|
|
||||||
let arrow;
|
let arrow;
|
||||||
let arrow_x;
|
let arrow_x;
|
||||||
let arrow_y = mouse_pos.1;
|
let arrow_y = mouse_pos.1;
|
||||||
@ -367,7 +363,7 @@ fn draw_tooltips(ecs: &World, ctx: &mut Rltk) {
|
|||||||
arrow = to_cp437('←');
|
arrow = to_cp437('←');
|
||||||
arrow_x = mouse_pos.0 + 1;
|
arrow_x = mouse_pos.0 + 1;
|
||||||
}
|
}
|
||||||
ctx.set(arrow_x, arrow_y, white, box_gray, arrow);
|
ctx.set(arrow_x, arrow_y, colors::WHITE, colors::BOX_GRAY, arrow);
|
||||||
|
|
||||||
let mut total_height = 0;
|
let mut total_height = 0;
|
||||||
for tt in tip_boxes.iter() {
|
for tt in tip_boxes.iter() {
|
||||||
@ -414,21 +410,15 @@ pub fn show_inventory(gs: &mut State, ctx: &mut Rltk) -> (ItemMenuResult, Option
|
|||||||
y - 2,
|
y - 2,
|
||||||
31,
|
31,
|
||||||
(count + 3) as i32,
|
(count + 3) as i32,
|
||||||
RGB::named(rltk::WHITE),
|
colors::WHITE,
|
||||||
RGB::named(rltk::BLACK),
|
colors::BLACK,
|
||||||
);
|
|
||||||
ctx.print_color(
|
|
||||||
18,
|
|
||||||
y - 2,
|
|
||||||
RGB::named(rltk::YELLOW),
|
|
||||||
RGB::named(rltk::BLACK),
|
|
||||||
"Inventory",
|
|
||||||
);
|
);
|
||||||
|
ctx.print_color(18, y - 2, colors::YELLOW, colors::BLACK, "Inventory");
|
||||||
ctx.print_color(
|
ctx.print_color(
|
||||||
18,
|
18,
|
||||||
y + count as i32 + 1,
|
y + count as i32 + 1,
|
||||||
RGB::named(rltk::YELLOW),
|
colors::YELLOW,
|
||||||
RGB::named(rltk::BLACK),
|
colors::BLACK,
|
||||||
"ESCAPE to cancel",
|
"ESCAPE to cancel",
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -439,27 +429,15 @@ pub fn show_inventory(gs: &mut State, ctx: &mut Rltk) -> (ItemMenuResult, Option
|
|||||||
.join()
|
.join()
|
||||||
.filter(|item| item.1.owner == *player_entity)
|
.filter(|item| item.1.owner == *player_entity)
|
||||||
{
|
{
|
||||||
ctx.set(
|
ctx.set(17, y, colors::WHITE, colors::BLACK, rltk::to_cp437('('));
|
||||||
17,
|
|
||||||
y,
|
|
||||||
RGB::named(rltk::WHITE),
|
|
||||||
RGB::named(rltk::BLACK),
|
|
||||||
rltk::to_cp437('('),
|
|
||||||
);
|
|
||||||
ctx.set(
|
ctx.set(
|
||||||
18,
|
18,
|
||||||
y,
|
y,
|
||||||
RGB::named(rltk::YELLOW),
|
colors::YELLOW,
|
||||||
RGB::named(rltk::BLACK),
|
colors::BLACK,
|
||||||
97 + j as rltk::FontCharType,
|
97 + j as rltk::FontCharType,
|
||||||
);
|
);
|
||||||
ctx.set(
|
ctx.set(19, y, colors::WHITE, colors::BLACK, rltk::to_cp437(')'));
|
||||||
19,
|
|
||||||
y,
|
|
||||||
RGB::named(rltk::WHITE),
|
|
||||||
RGB::named(rltk::BLACK),
|
|
||||||
rltk::to_cp437(')'),
|
|
||||||
);
|
|
||||||
|
|
||||||
ctx.print(21, y, &name.name.to_string());
|
ctx.print(21, y, &name.name.to_string());
|
||||||
equippable.push(entity);
|
equippable.push(entity);
|
||||||
@ -502,21 +480,15 @@ pub fn drop_item_menu(gs: &mut State, ctx: &mut Rltk) -> (ItemMenuResult, Option
|
|||||||
y - 2,
|
y - 2,
|
||||||
31,
|
31,
|
||||||
(count + 3) as i32,
|
(count + 3) as i32,
|
||||||
RGB::named(rltk::WHITE),
|
colors::WHITE,
|
||||||
RGB::named(rltk::BLACK),
|
colors::BLACK,
|
||||||
);
|
|
||||||
ctx.print_color(
|
|
||||||
18,
|
|
||||||
y - 2,
|
|
||||||
RGB::named(rltk::YELLOW),
|
|
||||||
RGB::named(rltk::BLACK),
|
|
||||||
"Drop Which Item?",
|
|
||||||
);
|
);
|
||||||
|
ctx.print_color(18, y - 2, colors::YELLOW, colors::BLACK, "Drop Which Item?");
|
||||||
ctx.print_color(
|
ctx.print_color(
|
||||||
18,
|
18,
|
||||||
y + count as i32 + 1,
|
y + count as i32 + 1,
|
||||||
RGB::named(rltk::YELLOW),
|
colors::YELLOW,
|
||||||
RGB::named(rltk::BLACK),
|
colors::BLACK,
|
||||||
"ESCAPE to cancel",
|
"ESCAPE to cancel",
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -527,27 +499,15 @@ pub fn drop_item_menu(gs: &mut State, ctx: &mut Rltk) -> (ItemMenuResult, Option
|
|||||||
.join()
|
.join()
|
||||||
.filter(|item| item.1.owner == *player_entity)
|
.filter(|item| item.1.owner == *player_entity)
|
||||||
{
|
{
|
||||||
ctx.set(
|
ctx.set(17, y, colors::WHITE, colors::BLACK, rltk::to_cp437('('));
|
||||||
17,
|
|
||||||
y,
|
|
||||||
RGB::named(rltk::WHITE),
|
|
||||||
RGB::named(rltk::BLACK),
|
|
||||||
rltk::to_cp437('('),
|
|
||||||
);
|
|
||||||
ctx.set(
|
ctx.set(
|
||||||
18,
|
18,
|
||||||
y,
|
y,
|
||||||
RGB::named(rltk::YELLOW),
|
colors::YELLOW,
|
||||||
RGB::named(rltk::BLACK),
|
colors::BLACK,
|
||||||
97 + j as rltk::FontCharType,
|
97 + j as rltk::FontCharType,
|
||||||
);
|
);
|
||||||
ctx.set(
|
ctx.set(19, y, colors::WHITE, colors::BLACK, rltk::to_cp437(')'));
|
||||||
19,
|
|
||||||
y,
|
|
||||||
RGB::named(rltk::WHITE),
|
|
||||||
RGB::named(rltk::BLACK),
|
|
||||||
rltk::to_cp437(')'),
|
|
||||||
);
|
|
||||||
|
|
||||||
ctx.print(21, y, &name.name.to_string());
|
ctx.print(21, y, &name.name.to_string());
|
||||||
equippable.push(entity);
|
equippable.push(entity);
|
||||||
@ -590,21 +550,21 @@ pub fn remove_item_menu(gs: &mut State, ctx: &mut Rltk) -> (ItemMenuResult, Opti
|
|||||||
y - 2,
|
y - 2,
|
||||||
31,
|
31,
|
||||||
(count + 3) as i32,
|
(count + 3) as i32,
|
||||||
RGB::named(rltk::WHITE),
|
colors::WHITE,
|
||||||
RGB::named(rltk::BLACK),
|
colors::BLACK,
|
||||||
);
|
);
|
||||||
ctx.print_color(
|
ctx.print_color(
|
||||||
18,
|
18,
|
||||||
y - 2,
|
y - 2,
|
||||||
RGB::named(rltk::YELLOW),
|
colors::YELLOW,
|
||||||
RGB::named(rltk::BLACK),
|
colors::BLACK,
|
||||||
"Remove Which Item?",
|
"Remove Which Item?",
|
||||||
);
|
);
|
||||||
ctx.print_color(
|
ctx.print_color(
|
||||||
18,
|
18,
|
||||||
y + count as i32 + 1,
|
y + count as i32 + 1,
|
||||||
RGB::named(rltk::YELLOW),
|
colors::YELLOW,
|
||||||
RGB::named(rltk::BLACK),
|
colors::BLACK,
|
||||||
"ESCAPE to cancel",
|
"ESCAPE to cancel",
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -615,27 +575,15 @@ pub fn remove_item_menu(gs: &mut State, ctx: &mut Rltk) -> (ItemMenuResult, Opti
|
|||||||
.join()
|
.join()
|
||||||
.filter(|item| item.1.owner == *player_entity)
|
.filter(|item| item.1.owner == *player_entity)
|
||||||
{
|
{
|
||||||
ctx.set(
|
ctx.set(17, y, colors::WHITE, colors::BLACK, rltk::to_cp437('('));
|
||||||
17,
|
|
||||||
y,
|
|
||||||
RGB::named(rltk::WHITE),
|
|
||||||
RGB::named(rltk::BLACK),
|
|
||||||
rltk::to_cp437('('),
|
|
||||||
);
|
|
||||||
ctx.set(
|
ctx.set(
|
||||||
18,
|
18,
|
||||||
y,
|
y,
|
||||||
RGB::named(rltk::YELLOW),
|
colors::YELLOW,
|
||||||
RGB::named(rltk::BLACK),
|
colors::BLACK,
|
||||||
97 + j as rltk::FontCharType,
|
97 + j as rltk::FontCharType,
|
||||||
);
|
);
|
||||||
ctx.set(
|
ctx.set(19, y, colors::WHITE, colors::BLACK, rltk::to_cp437(')'));
|
||||||
19,
|
|
||||||
y,
|
|
||||||
RGB::named(rltk::WHITE),
|
|
||||||
RGB::named(rltk::BLACK),
|
|
||||||
rltk::to_cp437(')'),
|
|
||||||
);
|
|
||||||
|
|
||||||
ctx.print(21, y, &name.name.to_string());
|
ctx.print(21, y, &name.name.to_string());
|
||||||
|
|
||||||
@ -673,13 +621,7 @@ pub fn ranged_target(
|
|||||||
let player_pos = gs.ecs.fetch::<Point>();
|
let player_pos = gs.ecs.fetch::<Point>();
|
||||||
let viewsheds = gs.ecs.read_storage::<Viewshed>();
|
let viewsheds = gs.ecs.read_storage::<Viewshed>();
|
||||||
|
|
||||||
ctx.print_color(
|
ctx.print_color(5, 0, colors::YELLOW, colors::BLACK, "Select Target:");
|
||||||
5,
|
|
||||||
0,
|
|
||||||
RGB::named(rltk::YELLOW),
|
|
||||||
RGB::named(rltk::BLACK),
|
|
||||||
"Select Target:",
|
|
||||||
);
|
|
||||||
|
|
||||||
// Highlight available target cells
|
// Highlight available target cells
|
||||||
let mut available_cells = Vec::new();
|
let mut available_cells = Vec::new();
|
||||||
@ -695,7 +637,7 @@ pub fn ranged_target(
|
|||||||
&& screen_y > 1
|
&& screen_y > 1
|
||||||
&& screen_y < (max_y - min_y) - 1
|
&& screen_y < (max_y - min_y) - 1
|
||||||
{
|
{
|
||||||
ctx.set_bg(screen_x, screen_y, RGB::named(rltk::BLUE));
|
ctx.set_bg(screen_x, screen_y, colors::BLUE);
|
||||||
available_cells.push(idx);
|
available_cells.push(idx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -717,7 +659,7 @@ pub fn ranged_target(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if valid_target {
|
if valid_target {
|
||||||
ctx.set_bg(mouse_pos.0, mouse_pos.1, RGB::named(rltk::CYAN));
|
ctx.set_bg(mouse_pos.0, mouse_pos.1, colors::CYAN);
|
||||||
if ctx.left_click {
|
if ctx.left_click {
|
||||||
return (
|
return (
|
||||||
ItemMenuResult::Selected,
|
ItemMenuResult::Selected,
|
||||||
@ -725,7 +667,7 @@ pub fn ranged_target(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ctx.set_bg(mouse_pos.0, mouse_pos.1, RGB::named(rltk::RED));
|
ctx.set_bg(mouse_pos.0, mouse_pos.1, colors::RED);
|
||||||
if ctx.left_click {
|
if ctx.left_click {
|
||||||
return (ItemMenuResult::Cancel, None);
|
return (ItemMenuResult::Cancel, None);
|
||||||
}
|
}
|
||||||
@ -753,31 +695,14 @@ pub fn main_menu(gs: &mut State, ctx: &mut Rltk) -> MainMenuResult {
|
|||||||
let assets = gs.ecs.fetch::<RexAssets>();
|
let assets = gs.ecs.fetch::<RexAssets>();
|
||||||
ctx.render_xp_sprite(&assets.menu, 0, 0);
|
ctx.render_xp_sprite(&assets.menu, 0, 0);
|
||||||
|
|
||||||
ctx.draw_box_double(
|
ctx.draw_box_double(24, 18, 31, 10, colors::WHEAT, colors::BLACK);
|
||||||
24,
|
|
||||||
18,
|
|
||||||
31,
|
|
||||||
10,
|
|
||||||
RGB::named(rltk::WHEAT),
|
|
||||||
RGB::named(rltk::BLACK),
|
|
||||||
);
|
|
||||||
|
|
||||||
ctx.print_color_centered(
|
ctx.print_color_centered(20, colors::YELLOW, colors::BLACK, "Rust Roguelike Tutorial");
|
||||||
20,
|
ctx.print_color_centered(21, colors::CYAN, colors::BLACK, "by Herbert Wolverson");
|
||||||
RGB::named(rltk::YELLOW),
|
|
||||||
RGB::named(rltk::BLACK),
|
|
||||||
"Rust Roguelike Tutorial",
|
|
||||||
);
|
|
||||||
ctx.print_color_centered(
|
|
||||||
21,
|
|
||||||
RGB::named(rltk::CYAN),
|
|
||||||
RGB::named(rltk::BLACK),
|
|
||||||
"by Herbert Wolverson",
|
|
||||||
);
|
|
||||||
ctx.print_color_centered(
|
ctx.print_color_centered(
|
||||||
22,
|
22,
|
||||||
RGB::named(rltk::GRAY),
|
colors::GRAY,
|
||||||
RGB::named(rltk::BLACK),
|
colors::BLACK,
|
||||||
"Use Up/Down Arrows and Enter",
|
"Use Up/Down Arrows and Enter",
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -787,50 +712,25 @@ pub fn main_menu(gs: &mut State, ctx: &mut Rltk) -> MainMenuResult {
|
|||||||
} = *runstate
|
} = *runstate
|
||||||
{
|
{
|
||||||
if selection == MainMenuSelection::NewGame {
|
if selection == MainMenuSelection::NewGame {
|
||||||
ctx.print_color_centered(
|
ctx.print_color_centered(y, colors::MAGENTA, colors::BLACK, "Begin New Game");
|
||||||
y,
|
|
||||||
RGB::named(rltk::MAGENTA),
|
|
||||||
RGB::named(rltk::BLACK),
|
|
||||||
"Begin New Game",
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
ctx.print_color_centered(
|
ctx.print_color_centered(y, colors::WHITE, colors::BLACK, "Begin New Game");
|
||||||
y,
|
|
||||||
RGB::named(rltk::WHITE),
|
|
||||||
RGB::named(rltk::BLACK),
|
|
||||||
"Begin New Game",
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
y += 1;
|
y += 1;
|
||||||
|
|
||||||
if save_exists {
|
if save_exists {
|
||||||
if selection == MainMenuSelection::LoadGame {
|
if selection == MainMenuSelection::LoadGame {
|
||||||
ctx.print_color_centered(
|
ctx.print_color_centered(y, colors::MAGENTA, colors::BLACK, "Load Game");
|
||||||
y,
|
|
||||||
RGB::named(rltk::MAGENTA),
|
|
||||||
RGB::named(rltk::BLACK),
|
|
||||||
"Load Game",
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
ctx.print_color_centered(
|
ctx.print_color_centered(y, colors::WHITE, colors::BLACK, "Load Game");
|
||||||
y,
|
|
||||||
RGB::named(rltk::WHITE),
|
|
||||||
RGB::named(rltk::BLACK),
|
|
||||||
"Load Game",
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
y += 1;
|
y += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if selection == MainMenuSelection::Quit {
|
if selection == MainMenuSelection::Quit {
|
||||||
ctx.print_color_centered(
|
ctx.print_color_centered(y, colors::MAGENTA, colors::BLACK, "Quit");
|
||||||
y,
|
|
||||||
RGB::named(rltk::MAGENTA),
|
|
||||||
RGB::named(rltk::BLACK),
|
|
||||||
"Quit",
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
ctx.print_color_centered(y, RGB::named(rltk::WHITE), RGB::named(rltk::BLACK), "Quit");
|
ctx.print_color_centered(y, colors::WHITE, colors::BLACK, "Quit");
|
||||||
}
|
}
|
||||||
|
|
||||||
return match ctx.key {
|
return match ctx.key {
|
||||||
@ -889,29 +789,24 @@ pub enum GameOverResult {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn game_over(ctx: &mut Rltk) -> GameOverResult {
|
pub fn game_over(ctx: &mut Rltk) -> GameOverResult {
|
||||||
ctx.print_color_centered(
|
ctx.print_color_centered(15, colors::YELLOW, colors::BLACK, "Your journey has ended!");
|
||||||
15,
|
|
||||||
RGB::named(rltk::YELLOW),
|
|
||||||
RGB::named(rltk::BLACK),
|
|
||||||
"Your journey has ended!",
|
|
||||||
);
|
|
||||||
ctx.print_color_centered(
|
ctx.print_color_centered(
|
||||||
17,
|
17,
|
||||||
RGB::named(rltk::WHITE),
|
colors::WHITE,
|
||||||
RGB::named(rltk::BLACK),
|
colors::BLACK,
|
||||||
"One day, we'll tell you all about how you did.",
|
"One day, we'll tell you all about how you did.",
|
||||||
);
|
);
|
||||||
ctx.print_color_centered(
|
ctx.print_color_centered(
|
||||||
18,
|
18,
|
||||||
RGB::named(rltk::WHITE),
|
colors::WHITE,
|
||||||
RGB::named(rltk::BLACK),
|
colors::BLACK,
|
||||||
"That day, sadly, is not in this chapter...",
|
"That day, sadly, is not in this chapter...",
|
||||||
);
|
);
|
||||||
|
|
||||||
ctx.print_color_centered(
|
ctx.print_color_centered(
|
||||||
20,
|
20,
|
||||||
RGB::named(rltk::MAGENTA),
|
colors::MAGENTA,
|
||||||
RGB::named(rltk::BLACK),
|
colors::BLACK,
|
||||||
"Press any key to return to the menu.",
|
"Press any key to return to the menu.",
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -939,118 +834,40 @@ pub fn show_cheat_mode(_gs: &mut State, ctx: &mut Rltk) -> CheatMenuResult {
|
|||||||
y - 2,
|
y - 2,
|
||||||
31,
|
31,
|
||||||
(count + 3) as i32,
|
(count + 3) as i32,
|
||||||
RGB::named(rltk::WHITE),
|
colors::WHITE,
|
||||||
RGB::named(rltk::BLACK),
|
colors::BLACK,
|
||||||
);
|
|
||||||
ctx.print_color(
|
|
||||||
18,
|
|
||||||
y - 2,
|
|
||||||
RGB::named(rltk::YELLOW),
|
|
||||||
RGB::named(rltk::BLACK),
|
|
||||||
"Cheating!",
|
|
||||||
);
|
);
|
||||||
|
ctx.print_color(18, y - 2, colors::YELLOW, colors::BLACK, "Cheating!");
|
||||||
ctx.print_color(
|
ctx.print_color(
|
||||||
18,
|
18,
|
||||||
y + count as i32 + 1,
|
y + count as i32 + 1,
|
||||||
RGB::named(rltk::YELLOW),
|
colors::YELLOW,
|
||||||
RGB::named(rltk::BLACK),
|
colors::BLACK,
|
||||||
"ESCAPE to cancel",
|
"ESCAPE to cancel",
|
||||||
);
|
);
|
||||||
|
|
||||||
ctx.set(
|
ctx.set(17, y, colors::WHITE, colors::BLACK, rltk::to_cp437('('));
|
||||||
17,
|
ctx.set(18, y, colors::YELLOW, colors::BLACK, rltk::to_cp437('T'));
|
||||||
y,
|
ctx.set(19, y, colors::WHITE, colors::BLACK, rltk::to_cp437(')'));
|
||||||
RGB::named(rltk::WHITE),
|
|
||||||
RGB::named(rltk::BLACK),
|
|
||||||
rltk::to_cp437('('),
|
|
||||||
);
|
|
||||||
ctx.set(
|
|
||||||
18,
|
|
||||||
y,
|
|
||||||
RGB::named(rltk::YELLOW),
|
|
||||||
RGB::named(rltk::BLACK),
|
|
||||||
rltk::to_cp437('T'),
|
|
||||||
);
|
|
||||||
ctx.set(
|
|
||||||
19,
|
|
||||||
y,
|
|
||||||
RGB::named(rltk::WHITE),
|
|
||||||
RGB::named(rltk::BLACK),
|
|
||||||
rltk::to_cp437(')'),
|
|
||||||
);
|
|
||||||
|
|
||||||
ctx.print(21, y, "Teleport to next level");
|
ctx.print(21, y, "Teleport to next level");
|
||||||
|
|
||||||
y += 1;
|
y += 1;
|
||||||
ctx.set(
|
ctx.set(17, y, colors::WHITE, colors::BLACK, rltk::to_cp437('('));
|
||||||
17,
|
ctx.set(18, y, colors::YELLOW, colors::BLACK, rltk::to_cp437('H'));
|
||||||
y,
|
ctx.set(19, y, colors::WHITE, colors::BLACK, rltk::to_cp437(')'));
|
||||||
RGB::named(rltk::WHITE),
|
|
||||||
RGB::named(rltk::BLACK),
|
|
||||||
rltk::to_cp437('('),
|
|
||||||
);
|
|
||||||
ctx.set(
|
|
||||||
18,
|
|
||||||
y,
|
|
||||||
RGB::named(rltk::YELLOW),
|
|
||||||
RGB::named(rltk::BLACK),
|
|
||||||
rltk::to_cp437('H'),
|
|
||||||
);
|
|
||||||
ctx.set(
|
|
||||||
19,
|
|
||||||
y,
|
|
||||||
RGB::named(rltk::WHITE),
|
|
||||||
RGB::named(rltk::BLACK),
|
|
||||||
rltk::to_cp437(')'),
|
|
||||||
);
|
|
||||||
ctx.print(21, y, "Heal all wounds");
|
ctx.print(21, y, "Heal all wounds");
|
||||||
|
|
||||||
y += 1;
|
y += 1;
|
||||||
ctx.set(
|
ctx.set(17, y, colors::WHITE, colors::BLACK, rltk::to_cp437('('));
|
||||||
17,
|
ctx.set(18, y, colors::YELLOW, colors::BLACK, rltk::to_cp437('R'));
|
||||||
y,
|
ctx.set(19, y, colors::WHITE, colors::BLACK, rltk::to_cp437(')'));
|
||||||
RGB::named(rltk::WHITE),
|
|
||||||
RGB::named(rltk::BLACK),
|
|
||||||
rltk::to_cp437('('),
|
|
||||||
);
|
|
||||||
ctx.set(
|
|
||||||
18,
|
|
||||||
y,
|
|
||||||
RGB::named(rltk::YELLOW),
|
|
||||||
RGB::named(rltk::BLACK),
|
|
||||||
rltk::to_cp437('R'),
|
|
||||||
);
|
|
||||||
ctx.set(
|
|
||||||
19,
|
|
||||||
y,
|
|
||||||
RGB::named(rltk::WHITE),
|
|
||||||
RGB::named(rltk::BLACK),
|
|
||||||
rltk::to_cp437(')'),
|
|
||||||
);
|
|
||||||
ctx.print(21, y, "Reveal the map");
|
ctx.print(21, y, "Reveal the map");
|
||||||
|
|
||||||
y += 1;
|
y += 1;
|
||||||
ctx.set(
|
ctx.set(17, y, colors::WHITE, colors::BLACK, rltk::to_cp437('('));
|
||||||
17,
|
ctx.set(18, y, colors::YELLOW, colors::BLACK, rltk::to_cp437('G'));
|
||||||
y,
|
ctx.set(19, y, colors::WHITE, colors::BLACK, rltk::to_cp437(')'));
|
||||||
RGB::named(rltk::WHITE),
|
|
||||||
RGB::named(rltk::BLACK),
|
|
||||||
rltk::to_cp437('('),
|
|
||||||
);
|
|
||||||
ctx.set(
|
|
||||||
18,
|
|
||||||
y,
|
|
||||||
RGB::named(rltk::YELLOW),
|
|
||||||
RGB::named(rltk::BLACK),
|
|
||||||
rltk::to_cp437('G'),
|
|
||||||
);
|
|
||||||
ctx.set(
|
|
||||||
19,
|
|
||||||
y,
|
|
||||||
RGB::named(rltk::WHITE),
|
|
||||||
RGB::named(rltk::BLACK),
|
|
||||||
rltk::to_cp437(')'),
|
|
||||||
);
|
|
||||||
ctx.print(21, y, "God Mode (No Death)");
|
ctx.print(21, y, "God Mode (No Death)");
|
||||||
|
|
||||||
match ctx.key {
|
match ctx.key {
|
||||||
@ -1099,21 +916,21 @@ fn vendor_sell_menu(
|
|||||||
y - 2,
|
y - 2,
|
||||||
51,
|
51,
|
||||||
(count + 3) as i32,
|
(count + 3) as i32,
|
||||||
RGB::named(rltk::WHITE),
|
colors::WHITE,
|
||||||
RGB::named(rltk::BLACK),
|
colors::BLACK,
|
||||||
);
|
);
|
||||||
ctx.print_color(
|
ctx.print_color(
|
||||||
18,
|
18,
|
||||||
y - 2,
|
y - 2,
|
||||||
RGB::named(rltk::YELLOW),
|
colors::YELLOW,
|
||||||
RGB::named(rltk::BLACK),
|
colors::BLACK,
|
||||||
"Sell Which Item? (space to switch to buy mode)",
|
"Sell Which Item? (space to switch to buy mode)",
|
||||||
);
|
);
|
||||||
ctx.print_color(
|
ctx.print_color(
|
||||||
18,
|
18,
|
||||||
y + count as i32 + 1,
|
y + count as i32 + 1,
|
||||||
RGB::named(rltk::YELLOW),
|
colors::YELLOW,
|
||||||
RGB::named(rltk::BLACK),
|
colors::BLACK,
|
||||||
"ESCAPE to cancel",
|
"ESCAPE to cancel",
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -1123,27 +940,15 @@ fn vendor_sell_menu(
|
|||||||
.filter(|item| item.1.owner == *player_entity)
|
.filter(|item| item.1.owner == *player_entity)
|
||||||
.enumerate()
|
.enumerate()
|
||||||
{
|
{
|
||||||
ctx.set(
|
ctx.set(17, y, colors::WHITE, colors::BLACK, rltk::to_cp437('('));
|
||||||
17,
|
|
||||||
y,
|
|
||||||
RGB::named(rltk::WHITE),
|
|
||||||
RGB::named(rltk::BLACK),
|
|
||||||
rltk::to_cp437('('),
|
|
||||||
);
|
|
||||||
ctx.set(
|
ctx.set(
|
||||||
18,
|
18,
|
||||||
y,
|
y,
|
||||||
RGB::named(rltk::YELLOW),
|
colors::YELLOW,
|
||||||
RGB::named(rltk::BLACK),
|
colors::BLACK,
|
||||||
97 + j as rltk::FontCharType,
|
97 + j as rltk::FontCharType,
|
||||||
);
|
);
|
||||||
ctx.set(
|
ctx.set(19, y, colors::WHITE, colors::BLACK, rltk::to_cp437(')'));
|
||||||
19,
|
|
||||||
y,
|
|
||||||
RGB::named(rltk::WHITE),
|
|
||||||
RGB::named(rltk::BLACK),
|
|
||||||
rltk::to_cp437(')'),
|
|
||||||
);
|
|
||||||
|
|
||||||
ctx.print(21, y, &name.name.to_string());
|
ctx.print(21, y, &name.name.to_string());
|
||||||
ctx.print(50, y, &format!("{:.1} gp", item.base_value * 0.8));
|
ctx.print(50, y, &format!("{:.1} gp", item.base_value * 0.8));
|
||||||
@ -1194,46 +999,34 @@ fn vendor_buy_menu(
|
|||||||
y - 2,
|
y - 2,
|
||||||
51,
|
51,
|
||||||
(count + 3) as i32,
|
(count + 3) as i32,
|
||||||
RGB::named(rltk::WHITE),
|
colors::WHITE,
|
||||||
RGB::named(rltk::BLACK),
|
colors::BLACK,
|
||||||
);
|
);
|
||||||
ctx.print_color(
|
ctx.print_color(
|
||||||
18,
|
18,
|
||||||
y - 2,
|
y - 2,
|
||||||
RGB::named(rltk::YELLOW),
|
colors::YELLOW,
|
||||||
RGB::named(rltk::BLACK),
|
colors::BLACK,
|
||||||
"Buy Which Item? (space to switch to sell mode)",
|
"Buy Which Item? (space to switch to sell mode)",
|
||||||
);
|
);
|
||||||
ctx.print_color(
|
ctx.print_color(
|
||||||
18,
|
18,
|
||||||
y + count as i32 + 1,
|
y + count as i32 + 1,
|
||||||
RGB::named(rltk::YELLOW),
|
colors::YELLOW,
|
||||||
RGB::named(rltk::BLACK),
|
colors::BLACK,
|
||||||
"ESCAPE to cancel",
|
"ESCAPE to cancel",
|
||||||
);
|
);
|
||||||
|
|
||||||
for (j, sale) in inventory.iter().enumerate() {
|
for (j, sale) in inventory.iter().enumerate() {
|
||||||
ctx.set(
|
ctx.set(17, y, colors::WHITE, colors::BLACK, rltk::to_cp437('('));
|
||||||
17,
|
|
||||||
y,
|
|
||||||
RGB::named(rltk::WHITE),
|
|
||||||
RGB::named(rltk::BLACK),
|
|
||||||
rltk::to_cp437('('),
|
|
||||||
);
|
|
||||||
ctx.set(
|
ctx.set(
|
||||||
18,
|
18,
|
||||||
y,
|
y,
|
||||||
RGB::named(rltk::YELLOW),
|
colors::YELLOW,
|
||||||
RGB::named(rltk::BLACK),
|
colors::BLACK,
|
||||||
97 + j as rltk::FontCharType,
|
97 + j as rltk::FontCharType,
|
||||||
);
|
);
|
||||||
ctx.set(
|
ctx.set(19, y, colors::WHITE, colors::BLACK, rltk::to_cp437(')'));
|
||||||
19,
|
|
||||||
y,
|
|
||||||
RGB::named(rltk::WHITE),
|
|
||||||
RGB::named(rltk::BLACK),
|
|
||||||
rltk::to_cp437(')'),
|
|
||||||
);
|
|
||||||
|
|
||||||
ctx.print(21, y, &sale.0);
|
ctx.print(21, y, &sale.0);
|
||||||
ctx.print(50, y, &format!("{:.1} gp", sale.1 * 1.2));
|
ctx.print(50, y, &format!("{:.1} gp", sale.1 * 1.2));
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
use ::rltk::RGB;
|
|
||||||
use ::specs::prelude::*;
|
use ::specs::prelude::*;
|
||||||
|
|
||||||
use crate::components::*;
|
use crate::components::*;
|
||||||
use crate::game_log::GameLog;
|
use crate::game_log::GameLog;
|
||||||
use crate::particle_system::ParticleBuilder;
|
use crate::particle_system::ParticleBuilder;
|
||||||
use crate::{spatial, Map, RunState};
|
use crate::{colors, spatial, Map, RunState};
|
||||||
|
|
||||||
pub struct ItemCollectionSystem {}
|
pub struct ItemCollectionSystem {}
|
||||||
|
|
||||||
@ -149,8 +148,8 @@ impl<'a> System<'a> for ItemUseSystem {
|
|||||||
particle_builder.request(
|
particle_builder.request(
|
||||||
tile_idx.x,
|
tile_idx.x,
|
||||||
tile_idx.y,
|
tile_idx.y,
|
||||||
RGB::named(rltk::ORANGE),
|
colors::ORANGE,
|
||||||
RGB::named(rltk::BLACK),
|
colors::BLACK,
|
||||||
rltk::to_cp437('░'),
|
rltk::to_cp437('░'),
|
||||||
200.0,
|
200.0,
|
||||||
);
|
);
|
||||||
@ -264,8 +263,8 @@ impl<'a> System<'a> for ItemUseSystem {
|
|||||||
particle_builder.request(
|
particle_builder.request(
|
||||||
pos.x,
|
pos.x,
|
||||||
pos.y,
|
pos.y,
|
||||||
RGB::named(rltk::GREEN),
|
colors::GREEN,
|
||||||
RGB::named(rltk::BLACK),
|
colors::BLACK,
|
||||||
rltk::to_cp437('♥'),
|
rltk::to_cp437('♥'),
|
||||||
200.0,
|
200.0,
|
||||||
);
|
);
|
||||||
@ -296,8 +295,8 @@ impl<'a> System<'a> for ItemUseSystem {
|
|||||||
particle_builder.request(
|
particle_builder.request(
|
||||||
pos.x,
|
pos.x,
|
||||||
pos.y,
|
pos.y,
|
||||||
RGB::named(rltk::RED),
|
colors::RED,
|
||||||
RGB::named(rltk::BLACK),
|
colors::BLACK,
|
||||||
rltk::to_cp437('‼'),
|
rltk::to_cp437('‼'),
|
||||||
200.0,
|
200.0,
|
||||||
);
|
);
|
||||||
@ -333,8 +332,8 @@ impl<'a> System<'a> for ItemUseSystem {
|
|||||||
particle_builder.request(
|
particle_builder.request(
|
||||||
pos.x,
|
pos.x,
|
||||||
pos.y,
|
pos.y,
|
||||||
RGB::named(rltk::MAGENTA),
|
colors::MAGENTA,
|
||||||
RGB::named(rltk::BLACK),
|
colors::BLACK,
|
||||||
rltk::to_cp437('?'),
|
rltk::to_cp437('?'),
|
||||||
200.0,
|
200.0,
|
||||||
);
|
);
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
use ::rltk::{Point, RGB};
|
use ::rltk::Point;
|
||||||
use ::specs::prelude::*;
|
use ::specs::prelude::*;
|
||||||
use rltk::DistanceAlg;
|
use rltk::DistanceAlg;
|
||||||
|
|
||||||
use super::{LightSource, Map, Position, Viewshed};
|
use super::{LightSource, Map, Position, Viewshed};
|
||||||
|
use crate::colors;
|
||||||
|
|
||||||
pub struct LightingSystem {}
|
pub struct LightingSystem {}
|
||||||
|
|
||||||
@ -22,9 +23,8 @@ impl<'a> System<'a> for LightingSystem {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let black = RGB::from_f32(0., 0., 0.);
|
|
||||||
for l in map.light.iter_mut() {
|
for l in map.light.iter_mut() {
|
||||||
*l = black;
|
*l = colors::BLACK;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (viewshed, pos, light) in (&viewshed, &positions, &lighting).join() {
|
for (viewshed, pos, light) in (&viewshed, &positions, &lighting).join() {
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
mod ai;
|
mod ai;
|
||||||
pub mod camera;
|
pub mod camera;
|
||||||
|
mod colors;
|
||||||
mod components;
|
mod components;
|
||||||
mod damage_system;
|
mod damage_system;
|
||||||
mod game_log;
|
mod game_log;
|
||||||
|
@ -12,7 +12,7 @@ pub use themes::*;
|
|||||||
pub use tiletype::{tile_opaque, tile_walkable, TileType};
|
pub use tiletype::{tile_opaque, tile_walkable, TileType};
|
||||||
|
|
||||||
use crate::map::tiletype::tile_cost;
|
use crate::map::tiletype::tile_cost;
|
||||||
use crate::spatial;
|
use crate::{colors, spatial};
|
||||||
|
|
||||||
#[derive(Default, Serialize, Deserialize, Clone)]
|
#[derive(Default, Serialize, Deserialize, Clone)]
|
||||||
pub struct Map {
|
pub struct Map {
|
||||||
@ -68,7 +68,7 @@ impl Map {
|
|||||||
view_blocked: HashSet::new(),
|
view_blocked: HashSet::new(),
|
||||||
name: name.to_string(),
|
name: name.to_string(),
|
||||||
outdoors: true,
|
outdoors: true,
|
||||||
light: vec![RGB::from_f32(0., 0., 0.); map_tile_count],
|
light: vec![colors::BLACK; map_tile_count],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
use ::rltk::{to_cp437, FontCharType, RGB};
|
use ::rltk::{to_cp437, FontCharType, RGB};
|
||||||
|
|
||||||
use super::{Map, TileType};
|
use super::{Map, TileType};
|
||||||
|
use crate::colors;
|
||||||
|
|
||||||
pub fn tile_glyph(idx: usize, map: &Map) -> (FontCharType, RGB, RGB) {
|
pub fn tile_glyph(idx: usize, map: &Map) -> (FontCharType, RGB, RGB) {
|
||||||
let (glyph, mut fg, mut bg) = match map.depth {
|
let (glyph, mut fg, mut bg) = match map.depth {
|
||||||
@ -10,12 +11,12 @@ pub fn tile_glyph(idx: usize, map: &Map) -> (FontCharType, RGB, RGB) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if map.bloodstains.contains(&idx) {
|
if map.bloodstains.contains(&idx) {
|
||||||
bg = RGB::from_f32(0.7, 0., 0.);
|
bg = colors::BLOOD;
|
||||||
}
|
}
|
||||||
|
|
||||||
if !map.visible_tiles[idx] {
|
if !map.visible_tiles[idx] {
|
||||||
fg = fg.to_greyscale();
|
fg = fg.to_greyscale();
|
||||||
bg = RGB::from_f32(0., 0., 0.);
|
bg = colors::BLACK;
|
||||||
} else if !map.outdoors {
|
} else if !map.outdoors {
|
||||||
fg = fg * map.light[idx];
|
fg = fg * map.light[idx];
|
||||||
bg = bg * map.light[idx];
|
bg = bg * map.light[idx];
|
||||||
@ -25,77 +26,77 @@ pub fn tile_glyph(idx: usize, map: &Map) -> (FontCharType, RGB, RGB) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn get_limestone_cavern_glyph(idx: usize, map: &Map) -> (FontCharType, RGB, RGB) {
|
fn get_limestone_cavern_glyph(idx: usize, map: &Map) -> (FontCharType, RGB, RGB) {
|
||||||
let bg = RGB::from_f32(0., 0., 0.);
|
let bg = colors::BLACK;
|
||||||
|
|
||||||
let (glyph, fg) = match map.tiles[idx] {
|
let (glyph, fg) = match map.tiles[idx] {
|
||||||
TileType::Wall => (to_cp437('▒'), RGB::from_f32(0.7, 0.7, 0.7)),
|
TileType::Wall => (to_cp437('▒'), colors::GRAY),
|
||||||
TileType::Bridge => (to_cp437('.'), RGB::named(rltk::CHOCOLATE)),
|
TileType::Bridge => (to_cp437('.'), colors::CHOCOLATE),
|
||||||
TileType::Road => (to_cp437('≡'), RGB::named(rltk::YELLOW)),
|
TileType::Road => (to_cp437('≡'), colors::YELLOW),
|
||||||
TileType::Grass => (to_cp437('"'), RGB::named(rltk::GREEN)),
|
TileType::Grass => (to_cp437('"'), colors::GREEN),
|
||||||
TileType::ShallowWater => (to_cp437('░'), RGB::named(rltk::CYAN)),
|
TileType::ShallowWater => (to_cp437('░'), colors::CYAN),
|
||||||
TileType::DeepWater => (to_cp437('▓'), RGB::from_f32(0.2, 0.2, 1.0)),
|
TileType::DeepWater => (to_cp437('▓'), colors::DEEP_WATER),
|
||||||
TileType::Gravel => (to_cp437(';'), RGB::from_f32(0.5, 0.5, 0.5)),
|
TileType::Gravel => (to_cp437(';'), colors::MID_GRAY),
|
||||||
TileType::DownStairs => (to_cp437('>'), RGB::from_f32(0., 1.0, 1.0)),
|
TileType::DownStairs => (to_cp437('>'), colors::CYAN),
|
||||||
TileType::UpStairs => (to_cp437('<'), RGB::from_f32(0., 1.0, 1.0)),
|
TileType::UpStairs => (to_cp437('<'), colors::CYAN),
|
||||||
TileType::Stalactite => (to_cp437('╨'), RGB::from_f32(0.5, 0.5, 0.5)),
|
TileType::Stalactite => (to_cp437('╨'), colors::MID_GRAY),
|
||||||
TileType::Stalagmite => (to_cp437('╥'), RGB::from_f32(0.5, 0.5, 0.5)),
|
TileType::Stalagmite => (to_cp437('╥'), colors::MID_GRAY),
|
||||||
_ => (to_cp437('░'), RGB::from_f32(0.4, 0.4, 0.4)),
|
_ => (to_cp437('░'), colors::DARK_GRAY),
|
||||||
};
|
};
|
||||||
|
|
||||||
(glyph, fg, bg)
|
(glyph, fg, bg)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_forest_glyph(idx: usize, map: &Map) -> (FontCharType, RGB, RGB) {
|
fn get_forest_glyph(idx: usize, map: &Map) -> (FontCharType, RGB, RGB) {
|
||||||
let bg = RGB::from_f32(0., 0., 0.);
|
let bg = colors::BLACK;
|
||||||
|
|
||||||
let (glyph, fg) = match map.tiles[idx] {
|
let (glyph, fg) = match map.tiles[idx] {
|
||||||
TileType::Wall => (to_cp437('♣'), RGB::from_f32(0.0, 0.6, 0.0)),
|
TileType::Wall => (to_cp437('♣'), colors::FOREST_GREEN),
|
||||||
TileType::Bridge => (to_cp437('.'), RGB::named(rltk::CHOCOLATE)),
|
TileType::Bridge => (to_cp437('.'), colors::CHOCOLATE),
|
||||||
TileType::Road => (to_cp437('≡'), RGB::named(rltk::YELLOW)),
|
TileType::Road => (to_cp437('≡'), colors::YELLOW),
|
||||||
TileType::Grass => (to_cp437('"'), RGB::named(rltk::GREEN)),
|
TileType::Grass => (to_cp437('"'), colors::GREEN),
|
||||||
TileType::ShallowWater => (to_cp437('~'), RGB::named(rltk::CYAN)),
|
TileType::ShallowWater => (to_cp437('~'), colors::CYAN),
|
||||||
TileType::DeepWater => (to_cp437('~'), RGB::named(rltk::BLUE)),
|
TileType::DeepWater => (to_cp437('~'), colors::DEEP_WATER),
|
||||||
TileType::Gravel => (to_cp437(';'), RGB::from_f32(0.5, 0.5, 0.5)),
|
TileType::Gravel => (to_cp437(';'), colors::MID_GRAY),
|
||||||
TileType::DownStairs => (to_cp437('>'), RGB::from_f32(0., 1.0, 1.0)),
|
TileType::DownStairs => (to_cp437('>'), colors::CYAN),
|
||||||
TileType::UpStairs => (to_cp437('<'), RGB::from_f32(0., 1.0, 1.0)),
|
TileType::UpStairs => (to_cp437('<'), colors::CYAN),
|
||||||
_ => (to_cp437('"'), RGB::from_f32(0.0, 0.6, 0.0)),
|
_ => (to_cp437('"'), colors::FOREST_GREEN),
|
||||||
};
|
};
|
||||||
|
|
||||||
(glyph, fg, bg)
|
(glyph, fg, bg)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_tile_glyph_default(idx: usize, map: &Map) -> (rltk::FontCharType, RGB, RGB) {
|
fn get_tile_glyph_default(idx: usize, map: &Map) -> (rltk::FontCharType, RGB, RGB) {
|
||||||
let mut bg = RGB::from_f32(0., 0., 0.);
|
let mut bg = colors::BLACK;
|
||||||
|
|
||||||
let (glyph, mut fg) = match map.tiles[idx] {
|
let (glyph, mut fg) = match map.tiles[idx] {
|
||||||
TileType::Floor => (to_cp437('.'), RGB::from_f32(0., 0.5, 0.5)),
|
TileType::Floor => (to_cp437('.'), colors::DEFAULT_FLOOR),
|
||||||
TileType::WoodFloor => (to_cp437('░'), RGB::named(rltk::CHOCOLATE)),
|
TileType::WoodFloor => (to_cp437('░'), colors::CHOCOLATE),
|
||||||
TileType::Wall => {
|
TileType::Wall => {
|
||||||
let x = idx as i32 % map.width;
|
let x = idx as i32 % map.width;
|
||||||
let y = idx as i32 / map.width;
|
let y = idx as i32 / map.width;
|
||||||
(wall_glyph(&*map, x, y), RGB::from_f32(0., 1.0, 0.))
|
(wall_glyph(&*map, x, y), colors::GREEN)
|
||||||
}
|
}
|
||||||
TileType::DownStairs => (to_cp437('>'), RGB::from_f32(0., 1.0, 1.0)),
|
TileType::DownStairs => (to_cp437('>'), colors::CYAN),
|
||||||
TileType::Bridge => (to_cp437('.'), RGB::named(rltk::CHOCOLATE)),
|
TileType::Bridge => (to_cp437('.'), colors::CHOCOLATE),
|
||||||
TileType::Road => (to_cp437('≡'), RGB::named(rltk::GRAY)),
|
TileType::Road => (to_cp437('≡'), colors::GRAY),
|
||||||
TileType::Grass => (to_cp437('"'), RGB::named(rltk::GREEN)),
|
TileType::Grass => (to_cp437('"'), colors::GREEN),
|
||||||
TileType::ShallowWater => (to_cp437('~'), RGB::named(rltk::CYAN)),
|
TileType::ShallowWater => (to_cp437('~'), colors::CYAN),
|
||||||
TileType::DeepWater => (to_cp437('~'), RGB::named(rltk::NAVY_BLUE)),
|
TileType::DeepWater => (to_cp437('~'), colors::DEEP_WATER),
|
||||||
TileType::Gravel => (to_cp437(';'), RGB::named(rltk::GRAY)),
|
TileType::Gravel => (to_cp437(';'), colors::GRAY),
|
||||||
TileType::UpStairs => (to_cp437('<'), RGB::from_f32(0., 1.0, 1.0)),
|
TileType::UpStairs => (to_cp437('<'), colors::CYAN),
|
||||||
TileType::Stalactite => (to_cp437('╨'), RGB::from_f32(0.5, 0.5, 0.5)),
|
TileType::Stalactite => (to_cp437('╨'), colors::MID_GRAY),
|
||||||
TileType::Stalagmite => (to_cp437('╥'), RGB::from_f32(0.5, 0.5, 0.5)),
|
TileType::Stalagmite => (to_cp437('╥'), colors::MID_GRAY),
|
||||||
};
|
};
|
||||||
|
|
||||||
if map.bloodstains.contains(&idx) {
|
if map.bloodstains.contains(&idx) {
|
||||||
bg = RGB::from_f32(0.75, 0., 0.);
|
bg = colors::BLOOD;
|
||||||
}
|
}
|
||||||
|
|
||||||
if !map.visible_tiles[idx] {
|
if !map.visible_tiles[idx] {
|
||||||
fg = fg.to_greyscale();
|
fg = fg.to_greyscale();
|
||||||
|
|
||||||
// Don't show bloodstains out of visual range
|
// Don't show bloodstains out of visual range
|
||||||
bg = RGB::from_f32(0., 0., 0.);
|
bg = colors::BLACK;
|
||||||
}
|
}
|
||||||
|
|
||||||
(glyph, fg, bg)
|
(glyph, fg, bg)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use ::rltk::{RandomNumberGenerator, RGB};
|
use ::rltk::RandomNumberGenerator;
|
||||||
use ::specs::prelude::*;
|
use ::specs::prelude::*;
|
||||||
|
|
||||||
use crate::components::{
|
use crate::components::{
|
||||||
@ -8,7 +8,7 @@ use crate::components::{
|
|||||||
use crate::game_log::GameLog;
|
use crate::game_log::GameLog;
|
||||||
use crate::gamesystem::skill_bonus;
|
use crate::gamesystem::skill_bonus;
|
||||||
use crate::particle_system::ParticleBuilder;
|
use crate::particle_system::ParticleBuilder;
|
||||||
use crate::{EquipmentSlot, NaturalAttackDefense, Position, WeaponAttribute};
|
use crate::{colors, EquipmentSlot, NaturalAttackDefense, Position, WeaponAttribute};
|
||||||
|
|
||||||
pub struct MeleeCombatSystem {}
|
pub struct MeleeCombatSystem {}
|
||||||
|
|
||||||
@ -171,8 +171,8 @@ impl<'a> System<'a> for MeleeCombatSystem {
|
|||||||
particle_builder.request(
|
particle_builder.request(
|
||||||
pos.x,
|
pos.x,
|
||||||
pos.y,
|
pos.y,
|
||||||
RGB::named(rltk::ORANGE),
|
colors::ORANGE,
|
||||||
RGB::named(rltk::BLACK),
|
colors::BLACK,
|
||||||
rltk::to_cp437('‼'),
|
rltk::to_cp437('‼'),
|
||||||
200.0,
|
200.0,
|
||||||
);
|
);
|
||||||
@ -187,8 +187,8 @@ impl<'a> System<'a> for MeleeCombatSystem {
|
|||||||
particle_builder.request(
|
particle_builder.request(
|
||||||
pos.x,
|
pos.x,
|
||||||
pos.y,
|
pos.y,
|
||||||
RGB::named(rltk::BLUE),
|
colors::BLUE,
|
||||||
RGB::named(rltk::BLACK),
|
colors::BLACK,
|
||||||
rltk::to_cp437('‼'),
|
rltk::to_cp437('‼'),
|
||||||
200.0,
|
200.0,
|
||||||
);
|
);
|
||||||
@ -203,8 +203,8 @@ impl<'a> System<'a> for MeleeCombatSystem {
|
|||||||
particle_builder.request(
|
particle_builder.request(
|
||||||
pos.x,
|
pos.x,
|
||||||
pos.y,
|
pos.y,
|
||||||
RGB::named(rltk::CYAN),
|
colors::CYAN,
|
||||||
RGB::named(rltk::BLACK),
|
colors::BLACK,
|
||||||
rltk::to_cp437('‼'),
|
rltk::to_cp437('‼'),
|
||||||
200.0,
|
200.0,
|
||||||
);
|
);
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
|
use ::serde::Deserialize;
|
||||||
|
|
||||||
use super::mob_structs::MobLight;
|
use super::mob_structs::MobLight;
|
||||||
use super::Renderable;
|
use super::Renderable;
|
||||||
use ::serde::Deserialize;
|
|
||||||
|
|
||||||
#[derive(Deserialize, Debug)]
|
#[derive(Deserialize, Debug)]
|
||||||
pub struct Prop {
|
pub struct Prop {
|
||||||
|
@ -204,8 +204,8 @@ fn get_renderable_component(
|
|||||||
) -> crate::components::Renderable {
|
) -> crate::components::Renderable {
|
||||||
crate::components::Renderable {
|
crate::components::Renderable {
|
||||||
glyph: rltk::to_cp437(renderable.glyph.chars().next().unwrap()),
|
glyph: rltk::to_cp437(renderable.glyph.chars().next().unwrap()),
|
||||||
fg: rltk::RGB::from_hex(&renderable.fg).expect("Invalid RGB"),
|
fg: RGB::from_hex(&renderable.fg).expect("Invalid color"),
|
||||||
bg: rltk::RGB::from_hex(&renderable.bg).expect("Invalid RGB"),
|
bg: RGB::from_hex(&renderable.bg).expect("Invalid color"),
|
||||||
render_order: renderable.order,
|
render_order: renderable.order,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -486,7 +486,7 @@ pub fn spawn_named_mob(
|
|||||||
if let Some(light) = &mob_template.light {
|
if let Some(light) = &mob_template.light {
|
||||||
eb = eb.with(LightSource {
|
eb = eb.with(LightSource {
|
||||||
range: light.range,
|
range: light.range,
|
||||||
color: RGB::from_hex(&light.color).expect("Bad color"),
|
color: RGB::from_hex(&light.color).expect("Invalid color"),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use ::rltk::{RandomNumberGenerator, RGB};
|
use ::rltk::RandomNumberGenerator;
|
||||||
use ::specs::prelude::*;
|
use ::specs::prelude::*;
|
||||||
use ::specs::saveload::{MarkedBuilder, SimpleMarker};
|
use ::specs::saveload::{MarkedBuilder, SimpleMarker};
|
||||||
|
|
||||||
@ -8,7 +8,7 @@ use crate::components::*;
|
|||||||
use crate::gamesystem::{mana_at_level, player_hp_at_level};
|
use crate::gamesystem::{mana_at_level, player_hp_at_level};
|
||||||
use crate::random_table::RandomTable;
|
use crate::random_table::RandomTable;
|
||||||
use crate::raws::{get_spawn_table_for_depth, spawn_named_entity, SpawnType, RAWS};
|
use crate::raws::{get_spawn_table_for_depth, spawn_named_entity, SpawnType, RAWS};
|
||||||
use crate::{Map, Rect, TileType};
|
use crate::{colors, Map, Rect, TileType};
|
||||||
|
|
||||||
/// Spawns the player and returns their entity object
|
/// Spawns the player and returns their entity object
|
||||||
pub fn player(ecs: &mut World, player_x: i32, player_y: i32) -> Entity {
|
pub fn player(ecs: &mut World, player_x: i32, player_y: i32) -> Entity {
|
||||||
@ -20,8 +20,8 @@ pub fn player(ecs: &mut World, player_x: i32, player_y: i32) -> Entity {
|
|||||||
})
|
})
|
||||||
.with(Renderable {
|
.with(Renderable {
|
||||||
glyph: rltk::to_cp437('@'),
|
glyph: rltk::to_cp437('@'),
|
||||||
fg: RGB::named(rltk::YELLOW),
|
fg: colors::YELLOW,
|
||||||
bg: RGB::named(rltk::BLACK),
|
bg: colors::BLACK,
|
||||||
render_order: 0,
|
render_order: 0,
|
||||||
})
|
})
|
||||||
.with(Player {})
|
.with(Player {})
|
||||||
@ -49,7 +49,7 @@ pub fn player(ecs: &mut World, player_x: i32, player_y: i32) -> Entity {
|
|||||||
god_mode: false,
|
god_mode: false,
|
||||||
})
|
})
|
||||||
.with(LightSource {
|
.with(LightSource {
|
||||||
color: RGB::from_f32(1.0, 1.0, 0.5),
|
color: colors::TORCH_LIGHT,
|
||||||
range: 8,
|
range: 8,
|
||||||
})
|
})
|
||||||
.with(Initiative { current: 0 })
|
.with(Initiative { current: 0 })
|
||||||
|
@ -6,7 +6,7 @@ use crate::components::{
|
|||||||
};
|
};
|
||||||
use crate::game_log::GameLog;
|
use crate::game_log::GameLog;
|
||||||
use crate::particle_system::ParticleBuilder;
|
use crate::particle_system::ParticleBuilder;
|
||||||
use crate::{spatial, Map};
|
use crate::{colors, spatial, Map};
|
||||||
|
|
||||||
pub struct TriggerSystem {}
|
pub struct TriggerSystem {}
|
||||||
|
|
||||||
@ -67,8 +67,8 @@ impl<'a> System<'a> for TriggerSystem {
|
|||||||
particle_builder.request(
|
particle_builder.request(
|
||||||
pos.x,
|
pos.x,
|
||||||
pos.y,
|
pos.y,
|
||||||
rltk::RGB::named(rltk::ORANGE),
|
colors::ORANGE,
|
||||||
rltk::RGB::named(rltk::BLACK),
|
colors::BLACK,
|
||||||
rltk::to_cp437('‼'),
|
rltk::to_cp437('‼'),
|
||||||
200.0,
|
200.0,
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user