aboutsummaryrefslogtreecommitdiff
path: root/src/mainMenu.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mainMenu.c')
-rw-r--r--src/mainMenu.c38
1 files changed, 35 insertions, 3 deletions
diff --git a/src/mainMenu.c b/src/mainMenu.c
index 10f293a..fc67972 100644
--- a/src/mainMenu.c
+++ b/src/mainMenu.c
@@ -1,14 +1,46 @@
#include "mainMenu.h"
#include "game.h"
+void initMainMenu(Game * game) {
+ game->mainMenu = (MainMenu){
+ .startButton = (Rectangle){0, 0, 100, 50},
+ .logoTexture = &game->assets.textures[ICON128_ASSET]
+ };
+
+ resizeMainMenu(game);
+}
+
void updateMainMenu(Game * game) {
+ MainMenu * mainMenu = &game->mainMenu;
ClearBackground(RAYWHITE);
- bool start = GuiButton(
- (Rectangle){10, 10, 100, 50},
- "Start"
+ // Logo.
+ DrawTextureV(
+ *mainMenu->logoTexture,
+ mainMenu->logoPosition,
+ WHITE
);
+ // Start button.
+ bool start = GuiButton(mainMenu->startButton, "Start");
+
if (start)
game->screenId = SCREEN_GAME;
+
+ if (IsWindowResized())
+ resizeMainMenu(game);
+}
+
+void resizeMainMenu(Game * game) {
+ MainMenu * mainMenu = &game->mainMenu;
+
+ // Logo.
+ mainMenu->logoPosition = (Vector2){
+ (GetScreenWidth() / 2.0) - (mainMenu->logoTexture->width / 2.0),
+ (GetScreenHeight() / 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);
}