aboutsummaryrefslogtreecommitdiff
path: root/src/screens/mainMenu.c
diff options
context:
space:
mode:
authornathansmithsmith <thenathansmithsmith@gmail.com>2023-12-22 12:37:18 -0700
committernathansmithsmith <thenathansmithsmith@gmail.com>2023-12-22 12:37:18 -0700
commit0be4fca7d5d05fe3cb161ed92218277f4af739e0 (patch)
tree1f2ddf753176698082433827bb47365671a476e6 /src/screens/mainMenu.c
parentad66d7ade0528829a48ac4426d952ec882ef4329 (diff)
Some info screen stuff
Diffstat (limited to 'src/screens/mainMenu.c')
-rw-r--r--src/screens/mainMenu.c33
1 files changed, 19 insertions, 14 deletions
diff --git a/src/screens/mainMenu.c b/src/screens/mainMenu.c
index 8cc2b09..76e7cb4 100644
--- a/src/screens/mainMenu.c
+++ b/src/screens/mainMenu.c
@@ -6,6 +6,7 @@ void initMainMenu(Game * game) {
game->mainMenu = (MainMenu){
.startButton = (Rectangle){0.0, 0.0, 100.0, 50.0},
.howToPlayButton = (Rectangle){0.0, 0.0, 100.0, 50.0},
+ .infoButton = (Rectangle){0.0, 0.0, 100.0, 50.0},
.logoTexture = &game->assets.textures[ICON128_ASSET]
};
@@ -23,32 +24,36 @@ void updateMainMenu(Game * game) {
WHITE
);
- // Start button.
- bool start = GuiButton(mainMenu->startButton, "Start");
-
- if (start)
+ if (GuiButton(mainMenu->startButton, "Start"))
openGameScreen(game);
- // How to play button.
- bool clickedHowToPlay = GuiButton(mainMenu->howToPlayButton, "How to play");
-
- if (clickedHowToPlay)
+ if (GuiButton(mainMenu->howToPlayButton, "How to play"))
game->screenId= HOW_TO_PLAY_SCREEN;
+
+ if (GuiButton(mainMenu->infoButton, "Info"))
+ game->screenId = INFO_SCREEN;
}
void resizeMainMenu(Game * game, MainMenu * mainMenu) {
+ int width = GetScreenWidth();
+ int height = GetScreenHeight();
+
// Logo.
mainMenu->logoPosition = (Vector2){
- (GetScreenWidth() / 2.0) - (mainMenu->logoTexture->width / 2.0),
- (GetScreenHeight() / 2.0) - (mainMenu->logoTexture->height * 1.50)
+ (width / 2.0) - (mainMenu->logoTexture->width / 2.0),
+ (height / 2.0) - (mainMenu->logoTexture->height * 1.50)
};
// Start button.
- mainMenu->startButton.x = (GetScreenWidth() / 2.0) - (mainMenu->startButton.width / 2.0);
- mainMenu->startButton.y = (GetScreenHeight() / 2.0) - (mainMenu->startButton.height / 2.0);
+ mainMenu->startButton.x = (width / 2.0) - (mainMenu->startButton.width / 2.0);
+ mainMenu->startButton.y = (height / 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.x = (width / 2.0) - (mainMenu->startButton.width / 2.0);
+ mainMenu->howToPlayButton.y = (height / 2.0) - (mainMenu->startButton.height / 2.0);
mainMenu->howToPlayButton.y += mainMenu->startButton.height;
+
+ // Info button.
+ mainMenu->infoButton.x = (width / 2.0) - (mainMenu->infoButton.width / 2.0);
+ mainMenu->infoButton.y = mainMenu->howToPlayButton.height + mainMenu->howToPlayButton.y;
}