add battery-ui #6
3 changed files with 34 additions and 2 deletions
15
src/game.rs
15
src/game.rs
|
@ -5,6 +5,20 @@ use crate::{
|
||||||
State
|
State
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct Gost {
|
||||||
LuckyTurtleDev marked this conversation as resolved
Outdated
|
|||||||
|
/// 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) {
|
pub fn update(state: &mut State, engine: &mut EngineContext) {
|
||||||
match state.activity {
|
match state.activity {
|
||||||
Activity::House => house::update(state, engine),
|
Activity::House => house::update(state, engine),
|
||||||
|
@ -17,4 +31,5 @@ pub fn draw(state: &State, engine: &EngineContext) {
|
||||||
Activity::House => house::draw(state, engine),
|
Activity::House => house::draw(state, engine),
|
||||||
Activity::Overworld => overworld::draw(state, engine)
|
Activity::Overworld => overworld::draw(state, engine)
|
||||||
}
|
}
|
||||||
|
crate::ui::draw(state, engine);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,20 +1,24 @@
|
||||||
mod activities;
|
mod activities;
|
||||||
mod game;
|
mod game;
|
||||||
|
mod ui;
|
||||||
|
|
||||||
use activities::Activity;
|
use activities::Activity;
|
||||||
use comfy::*;
|
use comfy::*;
|
||||||
|
use game::Gost;
|
||||||
|
|
||||||
const GAME_NAME: &str = "Powercreep";
|
const GAME_NAME: &str = "Powercreep";
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
struct State {
|
struct State {
|
||||||
activity: Activity
|
activity: Activity,
|
||||||
|
gohst: Gost,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for State {
|
impl Default for State {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
activity: Activity::House
|
activity: Activity::House,
|
||||||
|
gohst: Default::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
13
src/ui.rs
Normal file
13
src/ui.rs
Normal file
|
@ -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();
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
Loading…
Reference in a new issue
Ghost