From e5268813dcbdc0d90a081b2223ebc21749038635 Mon Sep 17 00:00:00 2001 From: nathansmithsmith Date: Fri, 7 Jul 2023 23:10:23 -0600 Subject: Better world --- src/mainMenu.c | 38 +++++++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) (limited to 'src/mainMenu.c') 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); } -- cgit v1.2.3