turtlegame/src/game.rs

43 lines
818 B
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;
#[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)
}
2024-07-05 21:10:25 +00:00
}