draw_hunger()

This commit is contained in:
Llywelwyn 2024-06-17 23:19:20 +01:00
parent d465592c0f
commit 6324449c16

View file

@ -150,46 +150,7 @@ fn draw_attributes(ctx: &mut BTerm, pt: Point, a: &Attributes) {
ctx.print_color(pt.x + 17, pt.y + 1, RGB::named(WHITE), RGB::named(BLACK), a.charisma.base);
}
pub fn draw_ui(ecs: &World, ctx: &mut BTerm) {
// Render stats
let pools = ecs.read_storage::<Pools>();
let attributes = ecs.read_storage::<Attributes>();
let players = ecs.read_storage::<Player>();
let hunger = ecs.read_storage::<HungerClock>();
let burden = ecs.read_storage::<Burden>();
let skills = ecs.read_storage::<Skills>();
for (_player, stats, attributes, hunger, skills) in (
&players,
&pools,
&attributes,
&hunger,
&skills,
).join() {
// Draw hp/mana bars
draw_lerping_bar(
ctx,
2,
53,
22,
stats.hit_points.current,
stats.hit_points.max,
RGB::from_u8(0, 255, 0),
RGB::from_u8(255, 0, 0)
);
draw_lerping_bar(
ctx,
2,
54,
22,
stats.mana.current,
stats.mana.max,
RGB::named(BLUE),
RGB::named(BLACK)
);
draw_ac(ctx, Point::new(26, 53), calc_ac(ecs, skills, stats, attributes));
draw_xp(ctx, Point::new(26, 54), stats);
draw_attributes(ctx, Point::new(38, 53), attributes);
// Draw hunger
fn draw_hunger(ctx: &mut BTerm, pt: Point, hunger: &HungerClock) {
match hunger.state {
HungerState::Satiated => {
ctx.print_color_right(
@ -238,6 +199,48 @@ pub fn draw_ui(ecs: &World, ctx: &mut BTerm) {
);
}
}
}
pub fn draw_ui(ecs: &World, ctx: &mut BTerm) {
// Render stats
let pools = ecs.read_storage::<Pools>();
let attributes = ecs.read_storage::<Attributes>();
let players = ecs.read_storage::<Player>();
let hunger = ecs.read_storage::<HungerClock>();
let burden = ecs.read_storage::<Burden>();
let skills = ecs.read_storage::<Skills>();
for (_player, stats, attributes, hunger, skills) in (
&players,
&pools,
&attributes,
&hunger,
&skills,
).join() {
// Draw hp/mana bars
draw_lerping_bar(
ctx,
2,
53,
22,
stats.hit_points.current,
stats.hit_points.max,
RGB::from_u8(0, 255, 0),
RGB::from_u8(255, 0, 0)
);
draw_lerping_bar(
ctx,
2,
54,
22,
stats.mana.current,
stats.mana.max,
RGB::named(BLUE),
RGB::named(BLACK)
);
draw_ac(ctx, Point::new(26, 53), calc_ac(ecs, skills, stats, attributes));
draw_xp(ctx, Point::new(26, 54), stats);
draw_attributes(ctx, Point::new(38, 53), attributes);
draw_hunger(ctx, Point::new(70, 53), hunger);
// Burden
let player_entity = ecs.fetch::<Entity>();
if let Some(burden) = burden.get(*player_entity) {