diff options
author | nathansmithsmith <thenathansmithsmith@gmail.com> | 2023-12-22 01:08:20 -0700 |
---|---|---|
committer | nathansmithsmith <thenathansmithsmith@gmail.com> | 2023-12-22 01:08:20 -0700 |
commit | fd0c7d4a5a23f6e8bfbafbed7d9bde319607451d (patch) | |
tree | d781d63da06d55ab23440e2a3baf919df2e4b826 | |
parent | 123e581f76d58df67bcf041f510c529601dae502 (diff) |
Started working on the how to play screen
-rw-r--r-- | src/game.c | 7 | ||||
-rw-r--r-- | src/game.h | 5 | ||||
-rw-r--r-- | src/howToPlayScreen.c | 13 | ||||
-rw-r--r-- | src/howToPlayScreen.h | 13 | ||||
-rw-r--r-- | src/mainMenu.c | 21 | ||||
-rw-r--r-- | src/mainMenu.h | 3 |
6 files changed, 53 insertions, 9 deletions
@@ -19,6 +19,9 @@ void initGame(Game * game) { // Main menu. initMainMenu(game); + // How to play screen. + initHowToPlayScreen(game); + // Camera. initCameras(game, game->cameras); @@ -49,6 +52,8 @@ void closeGame(Game * game) { void gameResize(Game * game) { resizeGameScreen(game, &game->gameScreen); + resizeMainMenu(game, &game->mainMenu); + resizeHowToPlayScreen(game, &game->howToPlayScreen); } void updateGame(Game * game) { @@ -61,6 +66,8 @@ void updateGame(Game * game) { case SCREEN_GAME: updateGameScreen(game); break; + case HOW_TO_PLAY_SCREEN: + updateHowToPlayScreen(game); default: break; } @@ -9,19 +9,22 @@ #include "bullets.h" #include "levels.h" #include "killLog.h" +#include "howToPlayScreen.h" #ifndef GAME_H #define GAME_H typedef enum ScreenId { SCREEN_MAIN_MENU, - SCREEN_GAME + SCREEN_GAME, + HOW_TO_PLAY_SCREEN } ScreenId; typedef struct Game { ScreenId screenId; MainMenu mainMenu; GameScreen gameScreen; + HowToPlayScreen howToPlayScreen; Cameras cameras; Assets assets; World world; diff --git a/src/howToPlayScreen.c b/src/howToPlayScreen.c new file mode 100644 index 0000000..abd7a01 --- /dev/null +++ b/src/howToPlayScreen.c @@ -0,0 +1,13 @@ +#include "howToPlayScreen.h" +#include "game.h" + +void initHowToPlayScreen(Game * game) { +} + +void updateHowToPlayScreen(Game * game) { + ClearBackground(RAYWHITE); + DrawText("hi", 100, 100, 20, BLACK); +} + +void resizeHowToPlayScreen(Game * game, HowToPlayScreen * howToPlayScreen) { +} diff --git a/src/howToPlayScreen.h b/src/howToPlayScreen.h new file mode 100644 index 0000000..86b720d --- /dev/null +++ b/src/howToPlayScreen.h @@ -0,0 +1,13 @@ +#include "gameCommon.h" + +#ifndef HOW_TO_PLAY_SCREEN_H +#define HOW_TO_PLAY_SCREEN_H + +typedef struct HowToPlayScreen { +} HowToPlayScreen; + +void initHowToPlayScreen(Game * game); +void updateHowToPlayScreen(Game * game); +void resizeHowToPlayScreen(Game * game, HowToPlayScreen * howToPlayScreen); + +#endif diff --git a/src/mainMenu.c b/src/mainMenu.c index c0568f9..8cc2b09 100644 --- a/src/mainMenu.c +++ b/src/mainMenu.c @@ -4,11 +4,12 @@ void initMainMenu(Game * game) { game->mainMenu = (MainMenu){ - .startButton = (Rectangle){0, 0, 100, 50}, + .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); + resizeMainMenu(game, &game->mainMenu); } void updateMainMenu(Game * game) { @@ -28,13 +29,14 @@ void updateMainMenu(Game * game) { if (start) openGameScreen(game); - if (IsWindowResized()) - resizeMainMenu(game); -} + // How to play button. + bool clickedHowToPlay = GuiButton(mainMenu->howToPlayButton, "How to play"); -void resizeMainMenu(Game * game) { - MainMenu * mainMenu = &game->mainMenu; + 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), @@ -44,4 +46,9 @@ void resizeMainMenu(Game * game) { // 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; } diff --git a/src/mainMenu.h b/src/mainMenu.h index 10ce855..c8bae78 100644 --- a/src/mainMenu.h +++ b/src/mainMenu.h @@ -8,10 +8,11 @@ typedef struct MainMenu { Texture2D * logoTexture; Rectangle startButton; + Rectangle howToPlayButton; } MainMenu; void initMainMenu(Game * game); void updateMainMenu(Game * game); -void resizeMainMenu(Game * game); +void resizeMainMenu(Game * game, MainMenu * mainMenu); #endif |