diff --git a/src/logic/mainmenu.rs b/src/logic/mainmenu.rs index e03d098..9f64a60 100644 --- a/src/logic/mainmenu.rs +++ b/src/logic/mainmenu.rs @@ -1,6 +1,10 @@ use raylib::prelude::*; -use crate::{gamecore::{GameCore, GameState}, lib::wrappers::audio::player::AudioPlayer, pallette::WATER_DARK}; +use crate::{ + gamecore::{GameCore, GameState}, + lib::wrappers::audio::player::AudioPlayer, + pallette::WATER_DARK, +}; use super::screen::Screen; @@ -38,10 +42,12 @@ impl Screen for MainMenuScreen { // Get mouse position data let mouse_position = draw_handle.get_mouse_position(); - let hovering_play_button = mouse_position.y > (win_width as f32 / 4.0) + let hovering_play_button = mouse_position.y > (win_width as f32 / 4.0) && mouse_position.y < (win_width as f32 / 4.0) + 60.0; - let hovering_quit_button = mouse_position.y > (win_width as f32 / 4.0) + 100.0 + let hovering_shop_button = mouse_position.y > (win_width as f32 / 4.0) + 100.0 && mouse_position.y < (win_width as f32 / 4.0) + 160.0; + let hovering_quit_button = mouse_position.y > (win_width as f32 / 4.0) + 200.0 + && mouse_position.y < (win_width as f32 / 4.0) + 260.0; // Play and quit draw_handle.draw_text( @@ -54,10 +60,20 @@ impl Screen for MainMenuScreen { false => Color::BLACK, }, ); + draw_handle.draw_text( + "Shop", + (win_height / 2) + 120, + (win_width / 4) + 100, + 60, + match hovering_shop_button { + true => Color::GREEN, + false => Color::BLACK, + }, + ); draw_handle.draw_text( "Quit", (win_height / 2) + 130, - (win_width / 4) + 100, + (win_width / 4) + 200, 60, match hovering_quit_button { true => Color::GREEN, @@ -72,7 +88,9 @@ impl Screen for MainMenuScreen { if mouse_clicked { if hovering_play_button { return Some(GameState::InGame); - } else if hovering_quit_button { + } else if hovering_shop_button { + return Some(GameState::InShop); + }else if hovering_quit_button { return Some(GameState::GameQuit); } } diff --git a/src/logic/pausemenu.rs b/src/logic/pausemenu.rs index 30c91f4..e89b0f1 100644 --- a/src/logic/pausemenu.rs +++ b/src/logic/pausemenu.rs @@ -157,7 +157,7 @@ impl Screen for PauseMenuScreen { }, ); draw_handle.draw_text( - "Quit", + "Menu", bottom_left_button_dimensions.x as i32 + 15, bottom_left_button_dimensions.y as i32 + 5, 30, @@ -182,7 +182,7 @@ impl Screen for PauseMenuScreen { // Handle click actions on the buttons if draw_handle.is_mouse_button_pressed(MouseButton::MOUSE_LEFT_BUTTON) { if mouse_over_bottom_left_button { - return Some(GameState::GameQuit); + return Some(GameState::MainMenu); } else if mouse_over_bottom_right_button { return Some(game_core.last_state); } diff --git a/src/logic/shopscreen.rs b/src/logic/shopscreen.rs index 8ca2c6e..43e7ddb 100644 --- a/src/logic/shopscreen.rs +++ b/src/logic/shopscreen.rs @@ -144,7 +144,7 @@ impl Screen for ShopScreen { }, ); draw_handle.draw_text( - "Quit", + "Menu", bottom_left_button_dimensions.x as i32 + 15, bottom_left_button_dimensions.y as i32 + 5, 30, @@ -159,7 +159,7 @@ impl Screen for ShopScreen { }, ); draw_handle.draw_text( - "Close", + "Play", bottom_right_button_dimensions.x as i32 + 15, bottom_right_button_dimensions.y as i32 + 5, 30, @@ -169,9 +169,9 @@ impl Screen for ShopScreen { // Handle click actions on the buttons if draw_handle.is_mouse_button_pressed(MouseButton::MOUSE_LEFT_BUTTON) { if mouse_over_bottom_left_button { - return Some(GameState::GameQuit); + return Some(GameState::MainMenu); } else if mouse_over_bottom_right_button { - return Some(game_core.last_state); + return Some(GameState::InGame); } }