From 6c63c3d327cf3b494309db82bdd4489b59d3d247 Mon Sep 17 00:00:00 2001 From: nathansmith117 Date: Tue, 20 Feb 2024 19:57:18 -0700 Subject: Button thingy working --- src/mainMenu.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'src/mainMenu.c') 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) -- cgit v1.2.3