scuffed entity chars

This commit is contained in:
Llywelwyn 2023-09-25 03:11:05 +01:00
parent 0586c2cdad
commit 6cc659fd23
3 changed files with 970 additions and 880 deletions

File diff suppressed because it is too large Load diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Before After
Before After

View file

@ -166,7 +166,12 @@ struct DrawInfo {
draw_type: DrawType, draw_type: DrawType,
} }
fn draw_camera(ecs: &World, draw: &mut Draw, atlas: &HashMap<String, Texture>) { fn draw_camera(
ecs: &World,
draw: &mut Draw,
atlas: &HashMap<String, Texture>,
font: &notan::draw::Font
) {
let map = ecs.fetch::<Map>(); let map = ecs.fetch::<Map>();
render_map_in_view(&*map, ecs, draw, atlas, false); render_map_in_view(&*map, ecs, draw, atlas, false);
{ {
@ -243,17 +248,30 @@ fn draw_camera(ecs: &World, draw: &mut Draw, atlas: &HashMap<String, Texture>) {
// Draw health bar // Draw health bar
} }
} }
draw.image(atlas.get("ui_heart_full").unwrap()).position( // TODO: Use sprites here, not text drawing. Put bitmap font into atlas.
(entry.0.x as f32) * TILESIZE, let renderable = renderables.get(entry.1.e).unwrap();
(entry.0.y as f32) * TILESIZE draw.text(&font, &format!("{}", renderable.glyph as u8 as char))
); .position(
((entry.0.x as f32) + 0.5) * TILESIZE,
((entry.0.y as f32) + 0.5) * TILESIZE
)
.color(Color::from_rgb(renderable.fg.r, renderable.fg.g, renderable.fg.b))
.size(FONTSIZE + 2.0)
.h_align_center()
.v_align_middle();
// Draw entity // Draw entity
} }
DrawType::VisibleAndRemember => { DrawType::VisibleAndRemember => {
draw.image(atlas.get("ui_crystal_full").unwrap()).position( let renderable = renderables.get(entry.1.e).unwrap();
(entry.0.x as f32) * TILESIZE, draw.text(&font, &format!("{}", renderable.glyph as u8 as char))
(entry.0.y as f32) * TILESIZE .position(
); ((entry.0.x as f32) + 0.5) * TILESIZE,
((entry.0.y as f32) + 0.5) * TILESIZE
)
.color(Color::from_rgb(renderable.fg.r, renderable.fg.g, renderable.fg.b))
.size(FONTSIZE + 2.0)
.h_align_center()
.v_align_middle();
// TODO: Update map memory. // TODO: Update map memory.
} }
_ => {} _ => {}
@ -373,15 +391,15 @@ use crate::consts::visuals::{ VIEWPORT_H, VIEWPORT_W };
fn draw_bg(_ecs: &World, draw: &mut Draw, atlas: &HashMap<String, Texture>) { fn draw_bg(_ecs: &World, draw: &mut Draw, atlas: &HashMap<String, Texture>) {
let offset = crate::camera::get_offset(); let offset = crate::camera::get_offset();
let log = BoxDraw { let log = BoxDraw {
frame: "ui_panel_window".to_string(), frame: "ui_panel_white".to_string(),
fill: true, fill: false,
top_left: (0, 0), top_left: (0, 0),
top_right: (offset.x + VIEWPORT_W, 0), top_right: (offset.x + VIEWPORT_W, 0),
bottom_left: (0, offset.y - 2), bottom_left: (0, offset.y - 2),
bottom_right: (offset.x + VIEWPORT_W, offset.y - 2), bottom_right: (offset.x + VIEWPORT_W, offset.y - 2),
}; };
let game = BoxDraw { let game = BoxDraw {
frame: "ui_panel_window".to_string(), frame: "ui_panel_white".to_string(),
fill: false, fill: false,
top_left: (offset.x - 1, offset.y - 1), top_left: (offset.x - 1, offset.y - 1),
top_right: (offset.x + VIEWPORT_W, offset.y - 1), top_right: (offset.x + VIEWPORT_W, offset.y - 1),
@ -389,16 +407,16 @@ fn draw_bg(_ecs: &World, draw: &mut Draw, atlas: &HashMap<String, Texture>) {
bottom_right: (offset.x + VIEWPORT_W, offset.y + VIEWPORT_H), bottom_right: (offset.x + VIEWPORT_W, offset.y + VIEWPORT_H),
}; };
let attr = BoxDraw { let attr = BoxDraw {
frame: "ui_panel_window".to_string(), frame: "ui_panel_white".to_string(),
fill: true, fill: false,
top_left: (offset.x - 1, offset.y + VIEWPORT_H + 1), top_left: (offset.x - 1, offset.y + VIEWPORT_H + 1),
top_right: (offset.x + VIEWPORT_W, offset.y + VIEWPORT_H + 1), top_right: (offset.x + VIEWPORT_W, offset.y + VIEWPORT_H + 1),
bottom_left: (offset.x - 1, (DISPLAYHEIGHT as i32) - 1), bottom_left: (offset.x - 1, (DISPLAYHEIGHT as i32) - 1),
bottom_right: (offset.x + VIEWPORT_W, (DISPLAYHEIGHT as i32) - 1), bottom_right: (offset.x + VIEWPORT_W, (DISPLAYHEIGHT as i32) - 1),
}; };
let sidebox = BoxDraw { let sidebox = BoxDraw {
frame: "ui_panel_window".to_string(), frame: "ui_panel_white".to_string(),
fill: true, fill: false,
top_left: (offset.x + VIEWPORT_W + 1, 0), top_left: (offset.x + VIEWPORT_W + 1, 0),
top_right: ((DISPLAYWIDTH as i32) - 1, 0), top_right: ((DISPLAYWIDTH as i32) - 1, 0),
bottom_left: (offset.x + VIEWPORT_W + 1, (DISPLAYHEIGHT as i32) - 1), bottom_left: (offset.x + VIEWPORT_W + 1, (DISPLAYHEIGHT as i32) - 1),
@ -429,7 +447,7 @@ fn draw(app: &mut App, gfx: &mut Graphics, gs: &mut State) {
} }
_ => { _ => {
draw_bg(&gs.ecs, &mut draw, &gs.atlas); draw_bg(&gs.ecs, &mut draw, &gs.atlas);
draw_camera(&gs.ecs, &mut draw, &gs.atlas); draw_camera(&gs.ecs, &mut draw, &gs.atlas, &gs.font);
crate::gui::draw_ui2(&gs.ecs, &mut draw, &gs.atlas, &gs.font); crate::gui::draw_ui2(&gs.ecs, &mut draw, &gs.atlas, &gs.font);
} }
} }