diff --git a/src/activities/house/room.rs b/src/activities/house/room.rs index 2c7c85c..9618f25 100644 --- a/src/activities/house/room.rs +++ b/src/activities/house/room.rs @@ -2,10 +2,10 @@ use super::{furniture::Furniture, grid::Grid}; use crate::game::{self, ZLayer}; use comfy::{ draw_rect, draw_rect_outline, draw_sprite, error, random_i32, vec2, EngineContext, - HashSet, Index, RandomRange as _, Vec2, GREEN, PURPLE, RED, WHITE - PURPLE, RED, WHITE + HashSet, RandomRange as _, Vec2, GREEN, PURPLE, RED, WHITE, }; use indexmap::IndexSet; +use comfy::texture_id; pub const SCALE: f32 = 4.0; diff --git a/src/game.rs b/src/game.rs index 6352858..31a4634 100644 --- a/src/game.rs +++ b/src/game.rs @@ -75,7 +75,8 @@ pub enum ZLayer { MapMax = -1, Human = 0, Ghost = 1, - UI = 100 + UI = 100, + GameOver = 1000, } impl From for i32 { @@ -134,6 +135,8 @@ pub const HOUSE_DISCHARGE_RATE: f32 = 30.0; pub const GHOST_CHARGE_RATE: f32 = 200.0; pub fn update(state: &mut State, ctx: &mut EngineContext<'_>) { + + if state.ghost.charge > 0.0 { // Update the score. It's based on time. state.score += ctx.delta * 10.0; @@ -168,6 +171,9 @@ pub fn update(state: &mut State, ctx: &mut EngineContext<'_>) { }, _ => {} } + }} + else { + crate::game_over::update(state, ctx); } // Make sure the ghost's charge never drops below 0. @@ -180,4 +186,7 @@ pub fn draw(state: &State, engine: &EngineContext<'_>) { Activity::Overworld => overworld::draw(state, engine) } crate::ui::draw(state, engine); + if state.ghost.charge <= 0.0 { + crate::game_over::draw(state, engine); + } }