turtlegame/src/game.rs

60 lines
1.1 KiB
Rust
Raw Normal View History

2024-07-06 11:33:58 +00:00
use crate::{
activities::{house, overworld, Activity},
State
};
use comfy::EngineContext;
use std::ops::Sub;
#[derive(Debug)]
pub struct Ghost {
/// current electric charge of the Ghost
pub charge: f32,
/// max electric charge of the Ghost
pub max_charge: f32
}
impl Default for Ghost {
fn default() -> Self {
Self {
charge: 1000.0,
max_charge: 1000.0
}
}
}
#[repr(i32)]
pub enum ZLayer {
MapMax = -1,
Human = 0,
Ghost = 1
}
impl From<ZLayer> for i32 {
fn from(value: ZLayer) -> Self {
// safe because #[repr(i32)]
value as i32
}
}
impl Sub<i32> for ZLayer {
type Output = i32;
fn sub(self, other: i32) -> Self::Output {
i32::from(self) - other
}
}
2024-07-05 21:10:25 +00:00
pub fn update(state: &mut State, engine: &mut EngineContext<'_>) {
2024-07-06 11:33:58 +00:00
match state.activity {
Activity::House => house::update(state, engine),
Activity::Overworld => overworld::update(state, engine)
}
}
2024-07-05 21:10:25 +00:00
pub fn draw(state: &State, engine: &EngineContext<'_>) {
2024-07-06 11:33:58 +00:00
match state.activity {
Activity::House => house::draw(state, engine),
Activity::Overworld => overworld::draw(state, engine)
}
crate::ui::draw(state, engine);
2024-07-05 21:10:25 +00:00
}