From fa7aa4d7ff9b93bf3ab8ce7098a83ead4539741a Mon Sep 17 00:00:00 2001 From: Marcelo Geldres Date: Sun, 3 Apr 2022 17:27:17 -0400 Subject: [PATCH] Return to Main menu and color varaibles too --- game/game_logic/src/scenes/pause_menu.rs | 44 +++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/game/game_logic/src/scenes/pause_menu.rs b/game/game_logic/src/scenes/pause_menu.rs index e7fc0d3e..a2b823bc 100644 --- a/game/game_logic/src/scenes/pause_menu.rs +++ b/game/game_logic/src/scenes/pause_menu.rs @@ -46,9 +46,17 @@ impl PauseMenu { // Get a drawing handle let mut draw = raylib.begin_drawing(rl_thread); + //Screen Size + let window_height = draw.get_screen_height(); + let window_width = draw.get_screen_width(); + // Clear the screen draw.clear_background(Color::WHITE); + //Color Pallette + let label_colors = Color::BLACK; + let label_shadow_colors = Color::GRAY; + //Obtain mouse position let mouse_x = draw.get_mouse_x(); let mouse_y = draw.get_mouse_y(); @@ -70,7 +78,41 @@ impl PauseMenu { } // Title - draw.draw_text("Paused", 100, 90, 60, Color::BLACK); + draw.draw_text("Paused", 100, 90, 60, label_colors); + + //Return to Main Menu button variables + let button_pos_x = 100; //116 Wide + let button_pos_y = window_height - (window_height / 5); //26 height + //Return to Main Menu Button + draw.draw_text("Return to Main Menu", button_pos_x, button_pos_y, 34, label_colors); + if mouse_x >= button_pos_x + && mouse_y >= button_pos_y + && mouse_x <= button_pos_x + 352 + && mouse_y <= button_pos_y + 23 + { + draw.draw_text( + "Return to Main Menu", + button_pos_x + 3, + button_pos_y + 1, + 34, + label_shadow_colors, + ); + draw.draw_text( + "Return to Main Menu", + button_pos_x, + button_pos_y, + 34, + label_colors + ); + + if draw.is_mouse_button_down(MouseButton::MOUSE_LEFT_BUTTON) { + audio_subsystem.play_sound(&global_resources.button_click_sound); + return MenuStateSignal::DoMainMenu; //Goes back to main menu + } + } + + + // Let the user leave this menu by pressing escape if draw.is_key_pressed(KeyboardKey::KEY_ESCAPE) {