made the switch to using bracket-lib directly, instead of rltk wrapper

this should solve the build issues; it makes using the non-crashing github build a lot easier, because it lets the explicit rltk dependency be removed.
This commit is contained in:
Llywelwyn 2023-09-05 02:23:31 +01:00
parent 455b8f2d80
commit 85efe13dc5
93 changed files with 1528 additions and 770 deletions

View file

@ -1,11 +1,11 @@
use super::{ Hidden, Map, Mind, Position, Prop, Renderable };
use rltk::prelude::*;
use bracket_lib::prelude::*;
use specs::prelude::*;
use std::ops::Mul;
const SHOW_BOUNDARIES: bool = false;
pub fn get_screen_bounds(ecs: &World, _ctx: &mut Rltk) -> (i32, i32, i32, i32, i32, i32) {
pub fn get_screen_bounds(ecs: &World, _ctx: &mut BTerm) -> (i32, i32, i32, i32, i32, i32) {
let player_pos = ecs.fetch::<Point>();
let map = ecs.fetch::<Map>();
let (x_chars, y_chars, mut x_offset, mut y_offset) = (69, 41, 1, 10);
@ -31,7 +31,7 @@ pub fn get_screen_bounds(ecs: &World, _ctx: &mut Rltk) -> (i32, i32, i32, i32, i
(min_x, max_x, min_y, max_y, x_offset, y_offset)
}
pub fn render_camera(ecs: &World, ctx: &mut Rltk) {
pub fn render_camera(ecs: &World, ctx: &mut BTerm) {
let map = ecs.fetch::<Map>();
let (min_x, max_x, min_y, max_y, x_offset, y_offset) = get_screen_bounds(ecs, ctx);
@ -52,7 +52,13 @@ pub fn render_camera(ecs: &World, ctx: &mut Rltk) {
ctx.set(x + x_offset, y + y_offset, fg, bg, glyph);
}
} else if SHOW_BOUNDARIES {
ctx.set(x + x_offset, y + y_offset, RGB::named(DARKSLATEGRAY), RGB::named(BLACK), rltk::to_cp437('#'));
ctx.set(
x + x_offset,
y + y_offset,
RGB::named(DARKSLATEGRAY),
RGB::named(BLACK),
to_cp437('#')
);
}
x += 1;
}
@ -112,14 +118,20 @@ pub fn render_camera(ecs: &World, ctx: &mut Rltk) {
}
}
if draw {
ctx.set(entity_offset_x + x_offset, entity_offset_y + y_offset, fg, bg, render.glyph);
ctx.set(
entity_offset_x + x_offset,
entity_offset_y + y_offset,
fg,
bg,
render.glyph
);
}
}
}
}
}
pub fn render_debug_map(map: &Map, ctx: &mut Rltk) {
pub fn render_debug_map(map: &Map, ctx: &mut BTerm) {
let player_pos = Point::new(map.width / 2, map.height / 2);
let (x_chars, y_chars) = ctx.get_char_size();
@ -141,11 +153,16 @@ pub fn render_debug_map(map: &Map, ctx: &mut Rltk) {
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) = crate::map::themes::get_tile_renderables_for_id(idx, &*map, None, None);
let (glyph, fg, bg) = crate::map::themes::get_tile_renderables_for_id(
idx,
&*map,
None,
None
);
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('·'));
ctx.set(x, y, RGB::named(GRAY), RGB::named(BLACK), to_cp437('·'));
}
x += 1;
}