#include "mainMenu.h" #include "game.h" #include "gameScreen.h" 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}, .logoTexture = &game->assets.textures[ICON128_ASSET] }; resizeMainMenu(game, &game->mainMenu); } void updateMainMenu(Game * game) { MainMenu * mainMenu = &game->mainMenu; ClearBackground(RAYWHITE); // Logo. DrawTextureV( *mainMenu->logoTexture, mainMenu->logoPosition, WHITE ); // Start button. bool start = GuiButton(mainMenu->startButton, "Start"); if (start) openGameScreen(game); // How to play button. bool clickedHowToPlay = GuiButton(mainMenu->howToPlayButton, "How to play"); 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), (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); // 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; }