From 194b12d6656a04f87ab99ad3526f1b1af888fdd2 Mon Sep 17 00:00:00 2001 From: luckyturtledev Date: Sat, 6 Jul 2024 18:51:21 +0200 Subject: [PATCH] start ui --- src/game.rs | 15 +++++++++++++++ src/main.rs | 8 ++++++-- src/ui.rs | 13 +++++++++++++ 3 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 src/ui.rs diff --git a/src/game.rs b/src/game.rs index a91fe39..a205c61 100644 --- a/src/game.rs +++ b/src/game.rs @@ -5,6 +5,20 @@ use crate::{ State }; +#[derive(Debug)] +pub struct Gost { + /// current electric charge of the Ghost + charge: u32, + /// max electric charge of the Ghost + max_charge: u32, +} + +impl Default for Gost { + fn default() -> Self { + Self { charge: 100, max_charge: 100 } + } +} + pub fn update(state: &mut State, engine: &mut EngineContext) { match state.activity { Activity::House => house::update(state, engine), @@ -17,4 +31,5 @@ pub fn draw(state: &State, engine: &EngineContext) { Activity::House => house::draw(state, engine), Activity::Overworld => overworld::draw(state, engine) } + crate::ui::draw(state, engine); } diff --git a/src/main.rs b/src/main.rs index 4992bdf..714ecd5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,20 +1,24 @@ mod activities; mod game; +mod ui; use activities::Activity; use comfy::*; +use game::Gost; const GAME_NAME: &str = "Powercreep"; #[derive(Debug)] struct State { - activity: Activity + activity: Activity, + gohst: Gost, } impl Default for State { fn default() -> Self { Self { - activity: Activity::House + activity: Activity::House, + gohst: Default::default(), } } } diff --git a/src/ui.rs b/src/ui.rs new file mode 100644 index 0000000..3bed45f --- /dev/null +++ b/src/ui.rs @@ -0,0 +1,13 @@ +use comfy::EngineContext; +use comfy::egui; +use comfy::RED; +use crate::State; + +pub fn draw(state: &State, engine: &EngineContext) { + egui::Area::new("batterie_show") + .anchor(egui::Align2::RIGHT_BOTTOM, egui::vec2(0.0, 0.0)) + .show(egui(), |ui| { + let painter = ui.painter(); + + }); +} \ No newline at end of file