aboutsummaryrefslogtreecommitdiffstats
path: root/src/mainMenu.c
diff options
context:
space:
mode:
authornathansmith117 <thenathansmithsmith@gmail.com>2024-02-21 02:57:18 +0000
committernathansmith117 <thenathansmithsmith@gmail.com>2024-02-21 02:57:18 +0000
commit6c63c3d327cf3b494309db82bdd4489b59d3d247 (patch)
treea5222a6e960e74f884299a558d8b103efcd6804d /src/mainMenu.c
parent801df9c821db87cf2e50f486c63ff083b375eb7e (diff)
downloadPenguinYippies-6c63c3d327cf3b494309db82bdd4489b59d3d247.tar.gz
PenguinYippies-6c63c3d327cf3b494309db82bdd4489b59d3d247.tar.bz2
PenguinYippies-6c63c3d327cf3b494309db82bdd4489b59d3d247.zip
Button thingy working
Diffstat (limited to 'src/mainMenu.c')
-rw-r--r--src/mainMenu.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/mainMenu.c b/src/mainMenu.c
index 6041e4b..f64c2be 100644
--- a/src/mainMenu.c
+++ b/src/mainMenu.c
@@ -4,10 +4,33 @@
void initMainMenu(MainMenu* mainMenu, Game* game)
{
+ // Start button stuff.
mainMenu->startButtonAnimation = createAnimation(
&game->assets.animations[BUTTON_BOX_ANIMATION],
ANIMATION_DEFAULT_DELAY
);
+
+ playAnimation(&mainMenu->startButtonAnimation);
+
+ Texture* startButtonTexture = &mainMenu->startButtonAnimation.texture;
+
+ int width = GetScreenWidth();
+ int height = GetScreenHeight();
+
+ mainMenu->startButton = createTexturedButton(
+ startButtonTexture,
+ (Rectangle){
+ width / 2.0 - startButtonTexture->width / 2.0,
+ height / 2.0 - startButtonTexture->height,
+ startButtonTexture->width,
+ startButtonTexture->height
+ },
+ "Start",
+ WHITE,
+ BLACK
+ );
+
+ mainMenu->startButton.fontSize = 50;
}
void updateMainMenu(MainMenu* mainMenu, Game* game)
@@ -23,6 +46,15 @@ void updateMainMenu(MainMenu* mainMenu, Game* game)
0.0,
WHITE
);
+
+ // Draw start button.
+ runAnimation(&mainMenu->startButtonAnimation);
+ bool startPressed = updateTexturedButton(&mainMenu->startButton);
+
+ if (startPressed)
+ {
+ game->currentScreen = GAME_SCREEN;
+ }
}
void closeMainMenu(MainMenu* mainMenu)