tweaks to make zoomfactor better - centred @ 2x zoom

This commit is contained in:
Llywelwyn 2023-10-06 10:33:25 +01:00
parent af1040b970
commit 40b048fd65
7 changed files with 17 additions and 14 deletions

View file

@ -13,7 +13,7 @@ pub struct Offsets {
} }
pub fn get_offset() -> Offsets { pub fn get_offset() -> Offsets {
return Offsets { x: 1, y: 10 }; return Offsets { x: 1, y: 8 };
} }
pub struct ScreenBounds { pub struct ScreenBounds {
@ -59,7 +59,7 @@ pub fn get_screen_bounds(ecs: &World, debug: bool) -> ScreenBounds {
TILES_IN_VIEWPORT_W, TILES_IN_VIEWPORT_W,
TILES_IN_VIEWPORT_H, TILES_IN_VIEWPORT_H,
1, 1,
10, 8,
); );
let centre_x = (x_chars / 2) as i32; let centre_x = (x_chars / 2) as i32;

View file

@ -1,4 +1,4 @@
pub const DEFAULT_VIEWSHED_STANDARD: i32 = 6; // Standard viewshed radius for almost all entities. pub const DEFAULT_VIEWSHED_STANDARD: i32 = 7; // Standard viewshed radius for almost all entities.
pub const CARRY_CAPACITY_PER_STRENGTH: i32 = 5; // How much weight can be carried per point of strength. pub const CARRY_CAPACITY_PER_STRENGTH: i32 = 5; // How much weight can be carried per point of strength.
pub const NORMAL_SPEED: i32 = 12; // Normal speed for almost all entities. pub const NORMAL_SPEED: i32 = 12; // Normal speed for almost all entities.
pub const SPEED_MOD_BURDENED: f32 = 0.75; pub const SPEED_MOD_BURDENED: f32 = 0.75;

View file

@ -28,4 +28,4 @@ pub const TILESIZE: Spritesize = Spritesize {
pub const ZOOM_FACTOR: f32 = 2.0; pub const ZOOM_FACTOR: f32 = 2.0;
pub const FONTSIZE: f32 = 16.0; pub const FONTSIZE: f32 = 16.0;
pub const DISPLAYWIDTH: u32 = 100; pub const DISPLAYWIDTH: u32 = 100;
pub const DISPLAYHEIGHT: u32 = 57; pub const DISPLAYHEIGHT: u32 = 58;

View file

@ -8,10 +8,10 @@ pub const WITH_DARKEN_BY_DISTANCE: bool = true; // If further away tiles should
// the viewport itself uses 16x24 sprites - so this translates to 70x28 tiles drawn. // the viewport itself uses 16x24 sprites - so this translates to 70x28 tiles drawn.
// It also works nicely for zooming in, displaying 35x14 tiles cleanly onscreen. // It also works nicely for zooming in, displaying 35x14 tiles cleanly onscreen.
pub const VIEWPORT_W: i32 = 70; pub const VIEWPORT_W: i32 = 70;
pub const VIEWPORT_H: i32 = 42; pub const VIEWPORT_H: i32 = 45;
pub const TILES_IN_VIEWPORT_W: i32 = 70 / (ZOOM_FACTOR as i32); pub const TILES_IN_VIEWPORT_W: i32 = 70 / (ZOOM_FACTOR as i32);
pub const TILES_IN_VIEWPORT_H: i32 = 28 / (ZOOM_FACTOR as i32); pub const TILES_IN_VIEWPORT_H: i32 = 30 / (ZOOM_FACTOR as i32);
pub const TILE_LAYER: usize = 1; pub const TILE_LAYER: usize = 1;
pub const ENTITY_LAYER: usize = 2; pub const ENTITY_LAYER: usize = 2;
@ -24,7 +24,7 @@ pub const GLOBAL_OFFSET_MAX_CLAMP: f32 = 1.0;
pub const SPRITE_OFFSET_MIN_CLAMP: f32 = 0.85; pub const SPRITE_OFFSET_MIN_CLAMP: f32 = 0.85;
pub const SPRITE_OFFSET_MAX_CLAMP: f32 = 1.0; pub const SPRITE_OFFSET_MAX_CLAMP: f32 = 1.0;
pub const WITH_SCANLINES_BRIGHTEN_AMOUNT: f32 = 0.1; // 0.0 = no brightening, 1.0 = full brightening. pub const WITH_SCANLINES_BRIGHTEN_AMOUNT: f32 = 0.1; // 0.0 = no brightening, 1.0 = full brightening.
pub const NON_VISIBLE_MULTIPLIER: f32 = 0.2; // 0.0 = black, 1.0 = full colour. pub const NON_VISIBLE_MULTIPLIER: f32 = 0.1; // 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. pub const NON_VISIBLE_MULTIPLIER_IF_SCANLINES: f32 = 0.8; // as above, but when using scanlines. should be higher.
pub const MAX_DARKENING: f32 = 0.2; // 0.0 = black, 1.0 = full colour - only used if WITH_DARKEN_BY_DISTANCE is true. pub const MAX_DARKENING: f32 = 0.2; // 0.0 = black, 1.0 = full colour - only used if WITH_DARKEN_BY_DISTANCE is true.
pub const MAX_DARKENING_IF_SCANLINES: f32 = 0.9; // as above, but when using scanlines. should be higher. pub const MAX_DARKENING_IF_SCANLINES: f32 = 0.9; // as above, but when using scanlines. should be higher.

View file

@ -18,9 +18,9 @@ pub fn render(draw: bool, gfx: &mut Graphics, font: &Fonts) {
render_log( render_log(
gfx, gfx,
&font, &font,
&(TILESIZE.x, TILESIZE.x * 8.0 + 4.0), &(TILESIZE.x, TILESIZE.x * 6.0 + 4.0),
(VIEWPORT_W as f32) * TILESIZE.x, (VIEWPORT_W as f32) * TILESIZE.x,
7 5
); );
} }
} }

View file

@ -3,7 +3,7 @@ use notan::draw::{ Draw, Font, DrawTextSection };
use specs::prelude::*; use specs::prelude::*;
use super::TILESIZE; use super::TILESIZE;
use crate::{ Fonts, camera::get_offset }; use crate::{ Fonts, camera::get_offset };
use super::{ items, Filter, print_options, ItemType }; use super::{ items, Filter, print_options, ItemType, FONTSIZE };
pub enum Location { pub enum Location {
All, All,
@ -46,7 +46,10 @@ pub fn draw_items(
if inv.is_empty() { if inv.is_empty() {
continue; continue;
} }
draw.text(&font.b(), itemtype.string()).position(x, y).color(Color::WHITE); draw.text(&font.b(), itemtype.string())
.position(x, y)
.color(Color::WHITE)
.size(FONTSIZE);
y += TILESIZE.x; y += TILESIZE.x;
y = print_options(ecs, draw, font, &inv, x, y) + TILESIZE.x; y = print_options(ecs, draw, font, &inv, x, y) + TILESIZE.x;
} }

View file

@ -187,7 +187,7 @@ pub fn draw_ui2(ecs: &World, draw: &mut Draw, atlas: &HashMap<String, Texture>,
draw_bar( draw_bar(
draw, draw,
BAR_X, BAR_X,
54.5, 55.5,
BAR_WIDTH, BAR_WIDTH,
TILESIZE.x, TILESIZE.x,
stats.hit_points.current, stats.hit_points.current,
@ -198,7 +198,7 @@ pub fn draw_ui2(ecs: &World, draw: &mut Draw, atlas: &HashMap<String, Texture>,
draw_bar( draw_bar(
draw, draw,
BAR_X, BAR_X,
55.5, 56.5,
BAR_WIDTH, BAR_WIDTH,
TILESIZE.x, TILESIZE.x,
stats.mana.current, stats.mana.current,
@ -208,7 +208,7 @@ pub fn draw_ui2(ecs: &World, draw: &mut Draw, atlas: &HashMap<String, Texture>,
); );
let initial_x = 24.0 * TILESIZE.x; let initial_x = 24.0 * TILESIZE.x;
let mut x = initial_x; let mut x = initial_x;
let row1 = 54.0 * TILESIZE.x; let row1 = 55.0 * TILESIZE.x;
let row2 = row1 + TILESIZE.x; let row2 = row1 + TILESIZE.x;
let hp_colours: (RGB, RGB, RGB) = ( let hp_colours: (RGB, RGB, RGB) = (
RGB::named(GREEN), RGB::named(GREEN),