From 0be4fca7d5d05fe3cb161ed92218277f4af739e0 Mon Sep 17 00:00:00 2001 From: nathansmithsmith Date: Fri, 22 Dec 2023 12:37:18 -0700 Subject: Some info screen stuff --- src/screens/howToPlayScreen.c | 4 +--- src/screens/infoScreen.c | 8 ++++++++ src/screens/infoScreen.h | 8 ++++++++ src/screens/mainMenu.c | 33 +++++++++++++++++++-------------- src/screens/mainMenu.h | 1 + 5 files changed, 37 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/screens/howToPlayScreen.c b/src/screens/howToPlayScreen.c index 8c31c20..ff6ccd2 100644 --- a/src/screens/howToPlayScreen.c +++ b/src/screens/howToPlayScreen.c @@ -16,9 +16,7 @@ void updateHowToPlayScreen(Game * game) { ClearBackground(RAYWHITE); // Back to main menu button. - bool backPressed = GuiButton(howToPlayScreen->goBackButton, "back"); - - if (backPressed) + if (GuiButton(howToPlayScreen->goBackButton, "Back")) game->screenId = SCREEN_MAIN_MENU; // Info text. diff --git a/src/screens/infoScreen.c b/src/screens/infoScreen.c index 8d991ed..86c0bb3 100644 --- a/src/screens/infoScreen.c +++ b/src/screens/infoScreen.c @@ -2,9 +2,17 @@ #include "game.h" void initInfoScreen(Game * game) { + InfoScreen * infoScreen = &game->infoScreen; + + infoScreen->goBackButton = (Rectangle){0.0, 25.0, 100.0, 50.0}; } void updateInfoScreen(Game * game) { + InfoScreen * infoScreen = &game->infoScreen; + ClearBackground(RAYWHITE); + + if (GuiButton(infoScreen->goBackButton, "Back")) + game->screenId = SCREEN_MAIN_MENU; } void resizeInfoScreen(Game * game, InfoScreen * infoScreen) { diff --git a/src/screens/infoScreen.h b/src/screens/infoScreen.h index 83a8059..a677a3d 100644 --- a/src/screens/infoScreen.h +++ b/src/screens/infoScreen.h @@ -1,9 +1,17 @@ #include "gameCommon.h" +#include "entity.h" +#include "assets.h" #ifndef INFO_SCREEN_H #define INFO_SCREEN_H +typedef struct EntityUserInfo { + EntityType type; + AssetId assetId; +} EntityUserInfo; + typedef struct InfoScreen { + Rectangle goBackButton; } InfoScreen; void initInfoScreen(Game * game); 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; } diff --git a/src/screens/mainMenu.h b/src/screens/mainMenu.h index c8bae78..0536e45 100644 --- a/src/screens/mainMenu.h +++ b/src/screens/mainMenu.h @@ -9,6 +9,7 @@ typedef struct MainMenu { Rectangle startButton; Rectangle howToPlayButton; + Rectangle infoButton; } MainMenu; void initMainMenu(Game * game); -- cgit v1.2.3