diff --git a/src/logic/gameend.rs b/src/logic/gameend.rs index 94690dd..0d2fc08 100644 --- a/src/logic/gameend.rs +++ b/src/logic/gameend.rs @@ -2,7 +2,7 @@ use raylib::prelude::*; use crate::{ gamecore::{GameCore, GameState}, - lib::wrappers::audio::player::AudioPlayer, + lib::{utils::button::OnScreenButton, wrappers::audio::player::AudioPlayer}, }; use super::screen::Screen; @@ -29,7 +29,6 @@ impl Screen for GameEndScreen { draw_handle.clear_background(Color::GRAY); // TODO: Maybe we can stick some art here? - // Window dimensions let win_height = draw_handle.get_screen_height(); let win_width = draw_handle.get_screen_width(); @@ -53,14 +52,48 @@ impl Screen for GameEndScreen { // Render heading text draw_handle.draw_text( "OUT OF BREATH", - (win_width / 2) - 80, + (win_width / 2) - ((SCREEN_PANEL_SIZE.x as i32 + 6) / 2) + 25, (win_height / 2) - (SCREEN_PANEL_SIZE.y as i32 / 2) + 10, - 40, + 30, Color::BLACK, ); - // TODO: Save game progress + // Render message + draw_handle.draw_text( + "Your clone can now buy items ", + ((win_width / 2) - ((SCREEN_PANEL_SIZE.x as i32 + 6) / 2)) + + (0.15 * SCREEN_PANEL_SIZE.x) as i32, + (win_height / 2) - (SCREEN_PANEL_SIZE.y as i32 / 2) + 50, + 15, + Color::BLACK, + ); + // Render button + let go_to_menu_button = OnScreenButton::new( + String::from("Return to shop"), + Rectangle { + x: (((win_width / 2) - ((SCREEN_PANEL_SIZE.x as i32 + 6) / 2) + 5) + + (0.15 * SCREEN_PANEL_SIZE.x) as i32) as f32, + y: (((win_height / 2) - (SCREEN_PANEL_SIZE.y as i32 / 2) + 90) as f32) + 100.0, + width: 210.0, + height: 50.0, + }, + Color::WHITE, + Color::BLACK, + Color::GRAY, + 25, + true, + ); + + go_to_menu_button.render(draw_handle); + + if go_to_menu_button.is_hovered(draw_handle) && draw_handle.is_mouse_button_pressed(MouseButton::MOUSE_LEFT_BUTTON){ + + game_core.switch_state(GameState::InShop, Some(draw_handle)); + + } + + // TODO: Save game progress // // Close and quit buttons // let bottom_left_button_dimensions = Rectangle { diff --git a/src/logic/ingame/mod.rs b/src/logic/ingame/mod.rs index ea95cf2..cb64580 100644 --- a/src/logic/ingame/mod.rs +++ b/src/logic/ingame/mod.rs @@ -216,6 +216,7 @@ impl Screen for InGameScreen { // Render the hud hud::render_hud(draw_handle, game_core, window_center); + // Handle player out of breath if game_core.player.breath_percent == 0.0 { return Some(GameState::GameEnd);