Module game_logic::scenes::main_menu [−][src]
Expand description
This scene encompasses the main menu system
+Module main_menu
Struct game_logic::scenes::main_menu::MainMenu [−][src]
pub struct MainMenu {
has_updated_discord_rpc: bool,
-}
Fields
has_updated_discord_rpc: bool
Implementations
pub fn new(
raylib_handle: &mut RaylibHandle,
thread: &RaylibThread,
constants: &ProjectConstants
) -> Self
pub fn new(
raylib_handle: &mut RaylibHandle,
thread: &RaylibThread,
constants: &ProjectConstants
) -> Self
Construct a new MainMenu
pub async fn render_options_frame(
&mut self,
raylib: &mut RaylibHandle,
rl_thread: &RaylibThread,
discord: &Sender<DiscordRpcSignal>,
global_resources: &GlobalResources,
constants: &ProjectConstants
) -> MenuStateSignal
pub async fn render_credits_frame(
&mut self,
raylib: &mut RaylibHandle,
rl_thread: &RaylibThread,
discord: &Sender<DiscordRpcSignal>,
global_resources: &GlobalResources,
constants: &ProjectConstants
) -> MenuStateSignal
pub async fn render_leaderboard_frame(
&mut self,
raylib: &mut RaylibHandle,
rl_thread: &RaylibThread,
discord: &Sender<DiscordRpcSignal>,
global_resources: &GlobalResources,
constants: &ProjectConstants
) -> MenuStateSignal
Trait Implementations
Formats the value using the given formatter. Read more
+}Fields
has_updated_discord_rpc: bool
Implementations
pub fn new(
raylib_handle: &mut RaylibHandle,
thread: &RaylibThread,
constants: &ProjectConstants
) -> Self
pub fn new(
raylib_handle: &mut RaylibHandle,
thread: &RaylibThread,
constants: &ProjectConstants
) -> Self
Construct a new MainMenu
pub async fn render_options_frame(
&mut self,
raylib: &mut RaylibHandle,
rl_thread: &RaylibThread,
discord: &Sender<DiscordRpcSignal>,
global_resources: &GlobalResources,
constants: &ProjectConstants
) -> MenuStateSignal
pub async fn render_credits_frame(
&mut self,
raylib: &mut RaylibHandle,
rl_thread: &RaylibThread,
discord: &Sender<DiscordRpcSignal>,
global_resources: &GlobalResources,
constants: &ProjectConstants
) -> MenuStateSignal
pub async fn render_leaderboard_frame(
&mut self,
raylib: &mut RaylibHandle,
rl_thread: &RaylibThread,
discord: &Sender<DiscordRpcSignal>,
global_resources: &GlobalResources,
constants: &ProjectConstants
) -> MenuStateSignal
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for MainMenu
impl UnwindSafe for MainMenu
Blanket Implementations
Mutably borrows from an owned value. Read more
diff --git a/rustdoc/src/game_logic/scenes/main_menu.rs.html b/rustdoc/src/game_logic/scenes/main_menu.rs.html index 0c56ed6d..b2f138af 100644 --- a/rustdoc/src/game_logic/scenes/main_menu.rs.html +++ b/rustdoc/src/game_logic/scenes/main_menu.rs.html @@ -256,6 +256,25 @@ 254 255 256 +257 +258 +259 +260 +261 +262 +263 +264 +265 +266 +267 +268 +269 +270 +271 +272 +273 +274 +275//! This scene encompasses the main menu system
use nalgebra as na;
@@ -348,7 +367,7 @@
//Insides while make a lil shade for it to look cool
draw.draw_text("Start Game", 103, 191, 34, Color::GRAY);
draw.draw_text("Start Game", 100, 190, 34, Color::BLACK);
- if draw.is_mouse_button_down(MouseButton::MOUSE_LEFT_BUTTON) {
+ if draw.is_mouse_button_pressed(MouseButton::MOUSE_LEFT_BUTTON) {
return MenuStateSignal::StartGame;
}
}
@@ -356,7 +375,7 @@
if mouse_x >= 100 && mouse_y >= 250 && mouse_x <= 222 && mouse_y <= 275 {
draw.draw_text("Options", 103, 251, 34, Color::GRAY);
draw.draw_text("Options", 100, 250, 34, Color::BLACK);
- if draw.is_mouse_button_down(MouseButton::MOUSE_LEFT_BUTTON) {
+ if draw.is_mouse_button_pressed(MouseButton::MOUSE_LEFT_BUTTON) {
return MenuStateSignal::DoOptions;
}
}
@@ -364,14 +383,14 @@
if mouse_x >= 100 && mouse_y >= 410 && mouse_x <= 222 && mouse_y <= 437 {
draw.draw_text("Credits", 103, 411, 34, Color::GRAY);
draw.draw_text("Credits", 100, 410, 34, Color::BLACK);
- if draw.is_mouse_button_down(MouseButton::MOUSE_LEFT_BUTTON) {
+ if draw.is_mouse_button_pressed(MouseButton::MOUSE_LEFT_BUTTON) {
return MenuStateSignal::DoCredits;
}
}
if mouse_x >= 100 && mouse_y >= 470 && mouse_x <= 316 && mouse_y <= 496 {
draw.draw_text("Leaderboard", 103, 471, 34, Color::GRAY);
draw.draw_text("Leaderboard", 100, 470, 34, Color::BLACK);
- if draw.is_mouse_button_down(MouseButton::MOUSE_LEFT_BUTTON) {
+ if draw.is_mouse_button_pressed(MouseButton::MOUSE_LEFT_BUTTON) {
return MenuStateSignal::DoLeaderboard;
}
}
@@ -379,7 +398,7 @@
if mouse_x >= 100 && mouse_y >= 300 && mouse_x <= 215 && mouse_y <= 330 {
draw.draw_text("Volume", 103, 301, 34, Color::GRAY);
draw.draw_text("Volume", 100, 300, 34, Color::BLACK);
- if draw.is_mouse_button_down(MouseButton::MOUSE_LEFT_BUTTON) {
+ if draw.is_mouse_button_pressed(MouseButton::MOUSE_LEFT_BUTTON) {
//Function for Volume here
}
}
@@ -388,6 +407,9 @@
if mouse_x >= 100 && mouse_y >= 550 && mouse_x <= 162 && mouse_y <= 575 {
draw.draw_text("Exit", 103, 551, 34, Color::GRAY);
draw.draw_text("Exit", 100, 550, 34, Color::BLACK);
+ if draw.is_mouse_button_pressed(MouseButton::MOUSE_LEFT_BUTTON) {
+ return MenuStateSignal::QuitGame;
+ }
}
@@ -419,16 +441,22 @@
//Top Label
draw.draw_text("Options", 25, 30, 55, Color::BLACK);
- //Return Button
- draw.draw_text("Return", 100, 550, 34, Color::BLACK);
- if mouse_x >= 100 && mouse_y >= 550 && mouse_x <= 216 && mouse_y <= 576 {
- draw.draw_text("Return", 103, 551, 34, Color::GRAY);
- draw.draw_text("Return", 100, 550, 34, Color::BLACK);
+ //Window size storing variables
+ let window_height = draw.get_screen_height();
+ let window_width = draw.get_screen_width();
+
+ //Return button variables
+ let button_pos_x = 100; //116 Wide
+ let button_pos_y = window_height - (window_height/5); //26 height
+
+ draw.draw_text("Return", button_pos_x, button_pos_y, 34, Color::BLACK);
+ if mouse_x >= 100 && mouse_y >= button_pos_y && mouse_x <= 216 && mouse_y <= (window_height - (window_height/5)) + 26 {
+ draw.draw_text("Return", button_pos_x + 3, button_pos_y + 1, 34, Color::GRAY);
+ draw.draw_text("Return", button_pos_x, button_pos_y, 34, Color::BLACK);
if draw.is_mouse_button_down(MouseButton::MOUSE_LEFT_BUTTON) {
return MenuStateSignal::DoMainMenu; //Goes back to main menu
}
}
-
return MenuStateSignal::DoOptions;
}
@@ -450,28 +478,31 @@
draw.draw_text(&mouse_y.to_string(), 70, 5, 20, Color::BLACK);
//Screen Size
- // let window_height = draw.get_screen_height();
+ let window_height = draw.get_screen_height();
let window_width = draw.get_screen_width();
draw.draw_text("Credits", (window_width/2) - 100, 30, 55, Color::BLACK);
- draw.draw_text("Carter Tomlenovich", (window_width/2) - 170, 280, 40, Color::DARKBLUE);
- draw.draw_text("Emilia Firas", (window_width/2) - 170, 120, 40, Color::DARKBLUE);
- draw.draw_text("Emmet Logue", (window_width/2) - 170, 320, 40, Color::DARKBLUE);
- draw.draw_text("Evan Pratten", (window_width/2) - 170, 160, 40, Color::DARKBLUE);
- draw.draw_text("James Nickoli", (window_width/2) - 170, 240, 40, Color::DARKBLUE);
- draw.draw_text("Marcelo Geldres", (window_width/2) - 170, 440, 40, Color::DARKBLUE);
- draw.draw_text("Percy", (window_width/2) - 170, 400, 40, Color::DARKBLUE);
- draw.draw_text("Silas Bartha", (window_width/2) - 170, 200, 40, Color::DARKBLUE);
- draw.draw_text("Taya Armstrong", (window_width/2) - 170, 360, 40, Color::DARKBLUE);
+ draw.draw_text("Carter Tomlenovich", (window_width/2) - 170, 120, 40, Color::DARKBLUE);
+ draw.draw_text("Emilia Firas", (window_width/2) - 170, 160, 40, Color::DARKBLUE);
+ draw.draw_text("Emmet Logue", (window_width/2) - 170, 200, 40, Color::DARKBLUE);
+ draw.draw_text("Evan Pratten", (window_width/2) - 170, 240, 40, Color::DARKBLUE);
+ draw.draw_text("James Nickoli", (window_width/2) - 170, 280, 40, Color::DARKBLUE);
+ draw.draw_text("Marcelo Geldres", (window_width/2) - 170, 320, 40, Color::DARKBLUE);
+ draw.draw_text("Percy", (window_width/2) - 170, 360, 40, Color::DARKBLUE);
+ draw.draw_text("Silas Bartha", (window_width/2) - 170, 400, 40, Color::DARKBLUE);
+ draw.draw_text("Taya Armstrong", (window_width/2) - 170, 440, 40, Color::DARKBLUE);
- //Return Button
- draw.draw_text("Return", 100, 550, 34, Color::BLACK);
- if mouse_x >= 100 && mouse_y >= 550 && mouse_x <= 216 && mouse_y <= 576 {
- draw.draw_text("Return", 103, 551, 34, Color::GRAY);
- draw.draw_text("Return", 100, 550, 34, Color::BLACK);
+ //Return button variables
+ let button_pos_x = 100; //116 Wide
+ let button_pos_y = window_height - (window_height/5); //26 height
+
+ draw.draw_text("Return", button_pos_x, button_pos_y, 34, Color::BLACK);
+ if mouse_x >= 100 && mouse_y >= button_pos_y && mouse_x <= 216 && mouse_y <= (window_height - (window_height/5)) + 26 {
+ draw.draw_text("Return", button_pos_x + 3, button_pos_y + 1, 34, Color::GRAY);
+ draw.draw_text("Return", button_pos_x, button_pos_y, 34, Color::BLACK);
if draw.is_mouse_button_down(MouseButton::MOUSE_LEFT_BUTTON) {
- return MenuStateSignal::DoMainMenu;
+ return MenuStateSignal::DoMainMenu; //Goes back to main menu
}
}
@@ -492,6 +523,10 @@
let mouse_x = draw.get_mouse_x();
let mouse_y = draw.get_mouse_y();
+ //Window size storing variables
+ let window_height = draw.get_screen_height();
+ let window_width = draw.get_screen_width();
+
//Show mouse position
draw.draw_text(&mouse_x.to_string(), 20, 5, 20, Color::BLACK);
draw.draw_text(&mouse_y.to_string(), 70, 5, 20, Color::BLACK);
@@ -499,13 +534,16 @@
let window_width = draw.get_screen_width();
draw.draw_text("Leaderboard", (window_width/2) - 176, 30, 55, Color::BLACK);
- //Return Button
- draw.draw_text("Return", 100, 550, 34, Color::BLACK);
- if mouse_x >= 100 && mouse_y >= 550 && mouse_x <= 216 && mouse_y <= 576 {
- draw.draw_text("Return", 103, 551, 34, Color::GRAY);
- draw.draw_text("Return", 100, 550, 34, Color::BLACK);
+ //Return button variables
+ let button_pos_x = 100; //116 Wide
+ let button_pos_y = window_height - (window_height/5); //26 height
+
+ draw.draw_text("Return", button_pos_x, button_pos_y, 34, Color::BLACK);
+ if mouse_x >= 100 && mouse_y >= button_pos_y && mouse_x <= 216 && mouse_y <= (window_height - (window_height/5)) + 26 {
+ draw.draw_text("Return", button_pos_x + 3, button_pos_y + 1, 34, Color::GRAY);
+ draw.draw_text("Return", button_pos_x, button_pos_y, 34, Color::BLACK);
if draw.is_mouse_button_down(MouseButton::MOUSE_LEFT_BUTTON) {
- return MenuStateSignal::DoMainMenu;
+ return MenuStateSignal::DoMainMenu; //Goes back to main menu
}
}