fn render_bar(
    panel: &mut Offscreen,
    x: i32,
    y: i32,
    total_width: i32,
    name: &str,
    value: i32,
    maximum: i32,
    bar_color: Color,
    back_color: Color,
) {
    // render a bar (HP, experience, etc). First calculate the width of the bar
    let bar_width = (value as f32 / maximum as f32 * total_width as f32) as i32;

    // render the background first
    panel.set_default_background(back_color);
    panel.rect(x, y, total_width, 1, false, BackgroundFlag::Screen);

    // now render the bar on top
    panel.set_default_background(bar_color);
    if bar_width > 0 {
        panel.rect(x, y, bar_width, 1, false, BackgroundFlag::Screen);
    }

    // finally, some centered text with the values
    panel.set_default_foreground(WHITE);
    panel.print_ex(
        x + total_width / 2,
        y,
        BackgroundFlag::None,
        TextAlignment::Center,
        &format!("{}: {}/{}", name, value, maximum),
    );
}
/// render a bar for the panel for health or mana or something
render a bar for the panel for health or mana or something
render a bar for the panel for health or mana or something
fn render_bar(
    panel: &mut Offscreen,
    x: i32,
    y: i32,
    total_width: i32,
    name: &str,
    value: i32,
    maximum: i32,
    bar_color: Color,
    back_color: Color,
) {
    // render a bar (HP, experience, etc). First calculate the width of the bar
    let bar_width = (value as f32 / maximum as f32 * total_width as f32) as i32;
    // render the background first
    panel.set_default_background(back_color);
    panel.rect(x, y, total_width, 1, false, BackgroundFlag::Screen);
    // now render the bar on top
    panel.set_default_background(bar_color);
    if bar_width > 0 {
        panel.rect(x, y, bar_width, 1, false, BackgroundFlag::Screen);
    }
    // finally, some centered text with the values
    panel.set_default_foreground(WHITE);
    panel.print_ex(
        x + total_width / 2,
        y,
        BackgroundFlag::None,
        TextAlignment::Center,
        &format!("{}: {}/{}", name, value, maximum),
    );
}
fn render_bar ( panel : & mut Offscreen , x : i32 , y : i32 , total_width : i32 , name : & str , value : i32 , maximum : i32 , bar_color : Color , back_color : Color , ) { // render a bar (HP, experience, etc). First calculate the width of the bar let bar_width = ( value as f32 / maximum as f32 * total_width as f32 ) as i32 ; // render the background first panel . set_default_background ( back_color ) ; panel . rect ( x , y , total_width , 1 , false , BackgroundFlag :: Screen ) ; // now render the bar on top panel . set_default_background ( bar_color ) ; if bar_width > 0 { panel . rect ( x , y , bar_width , 1 , false , BackgroundFlag :: Screen ) ; } // finally, some centered text with the values panel . set_default_foreground ( WHITE ) ; panel . print_ex ( x + total_width / 2 , y , BackgroundFlag :: None , TextAlignment :: Center , & format ! ( " " name value maximum ) , ) ; }
render a bar for the panel for health or mana or something
render a bar for the panel for health or mana or something
panel
&mut Offscreen
x
i32
y
i32
total_width
i32
name
&str
value
i32
maximum
i32
bar_color
Color
back_color
Color