finishes decoupling map from camera
This commit is contained in:
parent
2ecfd25d95
commit
7f0465da73
13 changed files with 110 additions and 254 deletions
|
|
@ -3,7 +3,7 @@ use rltk::{Point, Rltk, RGB};
|
|||
use specs::prelude::*;
|
||||
use std::ops::{Add, Mul};
|
||||
|
||||
const SHOW_BOUNDARIES: bool = true;
|
||||
const SHOW_BOUNDARIES: bool = false;
|
||||
|
||||
pub fn get_screen_bounds(ecs: &World, ctx: &mut Rltk) -> (i32, i32, i32, i32) {
|
||||
let player_pos = ecs.fetch::<Point>();
|
||||
|
|
@ -277,3 +277,37 @@ fn wall_glyph(map: &Map, x: i32, y: i32) -> rltk::FontCharType {
|
|||
_ => 35, // We missed one?
|
||||
}
|
||||
}
|
||||
|
||||
pub fn render_debug_map(map: &Map, ctx: &mut Rltk) {
|
||||
let player_pos = Point::new(map.width / 2, map.height / 2);
|
||||
let (x_chars, y_chars) = ctx.get_char_size();
|
||||
|
||||
let center_x = (x_chars / 2) as i32;
|
||||
let center_y = (y_chars / 2) as i32;
|
||||
|
||||
let min_x = player_pos.x - center_x;
|
||||
let max_x = min_x + x_chars as i32;
|
||||
let min_y = player_pos.y - center_y;
|
||||
let max_y = min_y + y_chars as i32;
|
||||
|
||||
let map_width = map.width - 1;
|
||||
let map_height = map.height - 1;
|
||||
|
||||
let mut y = 0;
|
||||
for ty in min_y..max_y {
|
||||
let mut x = 0;
|
||||
for tx in min_x..max_x {
|
||||
if tx > 0 && tx < map_width && ty > 0 && ty < map_height {
|
||||
let idx = map.xy_idx(tx, ty);
|
||||
if map.revealed_tiles[idx] {
|
||||
let (glyph, fg, bg) = get_tile_glyph(idx, &*map);
|
||||
ctx.set(x, y, fg, bg, glyph);
|
||||
}
|
||||
} else if SHOW_BOUNDARIES {
|
||||
ctx.set(x, y, RGB::named(rltk::GRAY), RGB::named(rltk::BLACK), rltk::to_cp437('·'));
|
||||
}
|
||||
x += 1;
|
||||
}
|
||||
y += 1;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue