aboutsummaryrefslogtreecommitdiff
path: root/src/mainMenu.c
diff options
context:
space:
mode:
authornathansmithsmith <thenathansmithsmith@gmail.com>2023-12-22 01:08:20 -0700
committernathansmithsmith <thenathansmithsmith@gmail.com>2023-12-22 01:08:20 -0700
commitfd0c7d4a5a23f6e8bfbafbed7d9bde319607451d (patch)
treed781d63da06d55ab23440e2a3baf919df2e4b826 /src/mainMenu.c
parent123e581f76d58df67bcf041f510c529601dae502 (diff)
Started working on the how to play screen
Diffstat (limited to 'src/mainMenu.c')
-rw-r--r--src/mainMenu.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/mainMenu.c b/src/mainMenu.c
index c0568f9..8cc2b09 100644
--- a/src/mainMenu.c
+++ b/src/mainMenu.c
@@ -4,11 +4,12 @@
void initMainMenu(Game * game) {
game->mainMenu = (MainMenu){
- .startButton = (Rectangle){0, 0, 100, 50},
+ .startButton = (Rectangle){0.0, 0.0, 100.0, 50.0},
+ .howToPlayButton = (Rectangle){0.0, 0.0, 100.0, 50.0},
.logoTexture = &game->assets.textures[ICON128_ASSET]
};
- resizeMainMenu(game);
+ resizeMainMenu(game, &game->mainMenu);
}
void updateMainMenu(Game * game) {
@@ -28,13 +29,14 @@ void updateMainMenu(Game * game) {
if (start)
openGameScreen(game);
- if (IsWindowResized())
- resizeMainMenu(game);
-}
+ // How to play button.
+ bool clickedHowToPlay = GuiButton(mainMenu->howToPlayButton, "How to play");
-void resizeMainMenu(Game * game) {
- MainMenu * mainMenu = &game->mainMenu;
+ if (clickedHowToPlay)
+ game->screenId= HOW_TO_PLAY_SCREEN;
+}
+void resizeMainMenu(Game * game, MainMenu * mainMenu) {
// Logo.
mainMenu->logoPosition = (Vector2){
(GetScreenWidth() / 2.0) - (mainMenu->logoTexture->width / 2.0),
@@ -44,4 +46,9 @@ void resizeMainMenu(Game * game) {
// Start button.
mainMenu->startButton.x = (GetScreenWidth() / 2.0) - (mainMenu->startButton.width / 2.0);
mainMenu->startButton.y = (GetScreenHeight() / 2.0) - (mainMenu->startButton.height / 2.0);
+
+ // How to play button.
+ mainMenu->howToPlayButton.x = (GetScreenWidth() / 2.0) - (mainMenu->startButton.width / 2.0);
+ mainMenu->howToPlayButton.y = (GetScreenHeight() / 2.0) - (mainMenu->startButton.height / 2.0);
+ mainMenu->howToPlayButton.y += mainMenu->startButton.height;
}