diff --git a/resources/curses8x16.pdn b/resources/curses8x16.pdn new file mode 100644 index 0000000..02b2112 Binary files /dev/null and b/resources/curses8x16.pdn differ diff --git a/resources/curses8x16.png b/resources/curses8x16.png new file mode 100644 index 0000000..4b83036 Binary files /dev/null and b/resources/curses8x16.png differ diff --git a/src/camera.rs b/src/camera.rs index 0d24e8a..f08d04b 100644 --- a/src/camera.rs +++ b/src/camera.rs @@ -132,13 +132,14 @@ pub fn render_camera(ecs: &World, ctx: &mut Rltk) { ctx.set_active_console(2); crate::gui::draw_lerping_bar( ctx, - (entity_offset_x + x_offset) * 22 + 2, - (entity_offset_y + y_offset) * 20 - 2, - 18, + (entity_offset_x + x_offset) * 16 + 2, + (entity_offset_y + y_offset) * 16 - 1, + 14, pool.hit_points.current, pool.hit_points.max, RGB::named(GREEN), RGB::named(RED), + false, false ); ctx.set_active_console(0); diff --git a/src/data/visuals.rs b/src/data/visuals.rs index a46ee1c..f57449b 100644 --- a/src/data/visuals.rs +++ b/src/data/visuals.rs @@ -1,7 +1,7 @@ // POST-PROCESSING 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 VIEWPORT_W: i32 = 40; -pub const VIEWPORT_H: i32 = 30; +pub const VIEWPORT_W: i32 = 69; +pub const VIEWPORT_H: i32 = 41; pub const BRIGHTEN_FG_COLOUR_BY: i32 = 16; pub const GLOBAL_OFFSET_MIN_CLAMP: f32 = -0.5; diff --git a/src/gui/mod.rs b/src/gui/mod.rs index 19d6849..5359344 100644 --- a/src/gui/mod.rs +++ b/src/gui/mod.rs @@ -85,21 +85,24 @@ pub fn draw_lerping_bar( max: i32, full_colour: RGB, empty_colour: RGB, - with_text: bool + with_text: bool, + with_bg: bool ) { let percent = (n as f32) / (max as f32); let fill_width = (percent * (width as f32)) as i32; let bg = empty_colour.lerp(full_colour, percent); - let fg = RGB::named(rltk::BLACK); + let black = RGB::named(rltk::BLACK); for x in 0..width { if x <= fill_width { - ctx.set(sx + x, sy, fg, bg, to_cp437(' ')); + ctx.print_color(sx + x, sy, black, bg, ' '); + } else if with_bg { + ctx.print_color(sx + x, sy, black, black, ' '); } } if with_text { ctx.print(sx - 1, sy, "["); let health = format!("{}/{}", n, max); - ctx.print_color(sx + 1, sy, fg, bg, health); + ctx.print_color(sx + 1, sy, black, bg, health); ctx.print(sx + width, sy, "]"); } } @@ -126,23 +129,25 @@ pub fn draw_ui(ecs: &World, ctx: &mut Rltk) { draw_lerping_bar( ctx, 2 * TEXT_FONT_MOD, - 53 * TEXT_FONT_MOD, - 22, + 53, + 22 * TEXT_FONT_MOD, stats.hit_points.current, stats.hit_points.max, RGB::from_u8(0, 255, 0), RGB::from_u8(255, 0, 0), + true, true ); draw_lerping_bar( ctx, 2 * TEXT_FONT_MOD, - 54 * TEXT_FONT_MOD, - 22, + 54, + 22 * TEXT_FONT_MOD, stats.mana.current, stats.mana.max, RGB::named(rltk::BLUE), RGB::named(rltk::BLACK), + true, true ); // Draw AC diff --git a/src/gui/tooltip.rs b/src/gui/tooltip.rs index c34782f..acd1d78 100644 --- a/src/gui/tooltip.rs +++ b/src/gui/tooltip.rs @@ -1,4 +1,16 @@ -use super::{ camera::get_screen_bounds, Attributes, Hidden, Map, Name, Pools, Position, Renderable, Rltk, World, RGB }; +use super::{ + camera::get_screen_bounds, + Attributes, + Hidden, + Map, + Name, + Pools, + Position, + Renderable, + Rltk, + World, + RGB, +}; use crate::TileType; use crate::data::ids::*; use rltk::prelude::*; @@ -34,10 +46,19 @@ impl Tooltip { return (self.lines.len() as i32) + 2i32; } fn render(&self, ctx: &mut Rltk, x: i32, y: i32) { - ctx.draw_box(x, y, self.width() - 1, self.height() - 1, RGB::named(WHITE), RGB::named(BLACK)); + ctx.set_active_console(1); + ctx.draw_box( + x, + y, + self.width() - 1, + self.height() - 1, + RGB::named(WHITE), + RGB::named(BLACK) + ); for (i, s) in self.lines.iter().enumerate() { ctx.print_color(x + 1, y + (i as i32) + 1, s.1, RGB::named(BLACK), &s.0); } + ctx.set_active_console(0); } } @@ -151,13 +172,15 @@ pub fn draw_tooltips(ecs: &World, ctx: &mut Rltk, xy: Option<(i32, i32)>) { if mouse_pos.0 > 35 { // Render to the left arrow = to_cp437('→'); - arrow_x = mouse_pos.0 - 1; + arrow_x = mouse_pos.0 * 2 - 1; } else { // Render to the right arrow = to_cp437('←'); - arrow_x = mouse_pos.0 + 1; + arrow_x = (mouse_pos.0 + 1) * 2; } + ctx.set_active_console(1); ctx.set(arrow_x, arrow_y, white, RGB::named(rltk::BLACK), arrow); + ctx.set_active_console(0); let mut total_height = 0; for t in tooltips.iter() { @@ -171,9 +194,9 @@ pub fn draw_tooltips(ecs: &World, ctx: &mut Rltk, xy: Option<(i32, i32)>) { for t in tooltips.iter() { let x = if mouse_pos.0 > 35 { - mouse_pos.0 - (1 + t.width()) + (mouse_pos.0 * 2) - (1 + t.width()) } else { - mouse_pos.0 + (1 + 1) + (mouse_pos.0 * 2) + 2 + 1 }; t.render(ctx, x, y); y += t.height(); diff --git a/src/main.rs b/src/main.rs index f926608..17a9b31 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,20 +3,20 @@ use specs::prelude::*; use specs::saveload::{ SimpleMarker, SimpleMarkerAllocator }; use rltk::prelude::*; -const DISPLAYWIDTH: i32 = 72; -const DISPLAYHEIGHT: i32 = 40; +const DISPLAYWIDTH: i32 = 105; +const DISPLAYHEIGHT: i32 = 56; fn main() -> rltk::BError { // Embedded resources for use in wasm build - const MAIN_22_20_BYTES: &[u8] = include_bytes!("../resources/nagidal22x20_centred.png"); - const TEXT_11_20_BYTES: &[u8] = include_bytes!("../resources/curses11x20.png"); + const CURSES_16_16_BYTES: &[u8] = include_bytes!("../resources/curses16x16.png"); + const CURSES_8_16_BYTES: &[u8] = include_bytes!("../resources/curses8x16.png"); const SINGLE_1_1_BYTES: &[u8] = include_bytes!("../resources/healthbar22x2.png"); rltk::embedding::EMBED .lock() - .add_resource("resources/nagidal22x20_centred.png".to_string(), MAIN_22_20_BYTES); + .add_resource("resources/curses16x16.png".to_string(), CURSES_16_16_BYTES); rltk::embedding::EMBED .lock() - .add_resource("resources/curses11x20.png".to_string(), TEXT_11_20_BYTES); + .add_resource("resources/curses8x16.png".to_string(), CURSES_8_16_BYTES); rltk::embedding::EMBED .lock() .add_resource("resources/healthbar22x2.png".to_string(), SINGLE_1_1_BYTES); @@ -24,14 +24,14 @@ fn main() -> rltk::BError { let mut context = RltkBuilder::new() .with_title("rust-rl") .with_dimensions(DISPLAYWIDTH, DISPLAYHEIGHT) - .with_font("nagidal22x20_centred.png", 22, 20) - .with_font("curses11x20.png", 11, 20) + .with_font("curses16x16.png", 16, 16) + .with_font("curses8x16.png", 8, 16) .with_font("healthbar22x2.png", 1, 1) - .with_tile_dimensions(22, 20) + .with_tile_dimensions(16, 16) .with_gutter(2) - .with_simple_console(DISPLAYWIDTH, DISPLAYHEIGHT, "nagidal22x20_centred.png") - .with_sparse_console(DISPLAYWIDTH * 2, DISPLAYHEIGHT, "curses11x20.png") - .with_sparse_console(DISPLAYWIDTH * 22, DISPLAYHEIGHT * 20, "healthbar22x2.png") + .with_simple_console(DISPLAYWIDTH, DISPLAYHEIGHT, "curses16x16.png") + .with_sparse_console(DISPLAYWIDTH * 2, DISPLAYHEIGHT, "curses8x16.png") + .with_sparse_console(DISPLAYWIDTH * 16, DISPLAYHEIGHT * 16, "healthbar22x2.png") .build()?; if config::CONFIG.visuals.with_scanlines { context.with_post_scanlines(config::CONFIG.visuals.with_screen_burn);