32 lines
1.1 KiB
Rust
32 lines
1.1 KiB
Rust
|
use crate::State;
|
||
|
use comfy::{
|
||
|
draw_rect, draw_rect_outline, screen_height, screen_to_world, screen_width,
|
||
|
EngineContext, Vec2, BLUE, RED
|
||
|
};
|
||
|
|
||
|
pub fn draw(state: &State, _engine: &EngineContext<'_>) {
|
||
|
// seperate fill state into smaller section for better readability
|
||
|
let section_count = 5;
|
||
|
let mut start_positon = screen_to_world(Vec2::new(screen_width(), screen_height()));
|
||
|
// section size in world codinates
|
||
|
let section_size = Vec2::new(0.5, 0.25);
|
||
|
start_positon.x -= 0.5 * section_size.x + 0.5 * section_size.y;
|
||
|
start_positon.y += 0.5 * section_size.y + 0.5 * section_size.y;
|
||
|
// draw fill level
|
||
|
{
|
||
|
let ghost = &state.ghost;
|
||
|
let percent = ghost.charge / ghost.max_charge;
|
||
|
let mut size = section_size;
|
||
|
size.y = section_size.y * section_count as f32 * percent;
|
||
|
let mut position = start_positon;
|
||
|
position.y += 0.5 * -section_size.y + 0.5 * size.y;
|
||
|
draw_rect(position, size, BLUE, 100);
|
||
|
}
|
||
|
// draw sections
|
||
|
for i in 0 .. section_count {
|
||
|
let mut position = start_positon;
|
||
|
position.y += i as f32 * section_size.y;
|
||
|
draw_rect_outline(position, section_size, 0.1, RED, 100);
|
||
|
}
|
||
|
}
|