From 76aa6ea16db1bfee36f86f461ea8487c60296973 Mon Sep 17 00:00:00 2001 From: nathansmith117 Date: Tue, 20 Feb 2024 20:37:40 -0700 Subject: Button panel --- src/gameScreen.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 53 insertions(+), 2 deletions(-) (limited to 'src/gameScreen.c') diff --git a/src/gameScreen.c b/src/gameScreen.c index 1af0faf..96c1ed6 100644 --- a/src/gameScreen.c +++ b/src/gameScreen.c @@ -1,8 +1,10 @@ #include "gameScreen.h" #include "game.h" +#include "assets.h" void initGameScreen(GameScreen* gameScreen, Game* game) { + Assets* assets = &game->assets; int width = GetScreenWidth(); int height = GetScreenHeight(); int navigationButtonSize = 100; @@ -10,7 +12,7 @@ void initGameScreen(GameScreen* gameScreen, Game* game) // Navigation buttons. gameScreen->toGameButton = createTexturedButton( - &game->assets.textures[TO_GAME_ICON_TEXTURE], + &assets->textures[TO_GAME_ICON_TEXTURE], (Rectangle){navigationButtonX, 5.0, navigationButtonSize, navigationButtonSize}, "", WHITE, @@ -18,12 +20,53 @@ void initGameScreen(GameScreen* gameScreen, Game* game) ); gameScreen->toEmperorsEmporiumButton = createTexturedButton( - &game->assets.textures[TO_EMPERORS_EMPORIUM_ICON_TEXTURE], + &assets->textures[TO_EMPERORS_EMPORIUM_ICON_TEXTURE], (Rectangle){navigationButtonX, navigationButtonSize + 15.0, navigationButtonSize, navigationButtonSize}, "", WHITE, BLACK ); + + // Button pannel thingy. + gameScreen->buttonPanelSharedAnimation = createAnimation(&assets->animations[BUTTON_BOX_ANIMATION], ANIMATION_DEFAULT_DELAY); + playAnimation(&gameScreen->buttonPanelSharedAnimation); + + Texture* buttonTexture = &gameScreen->buttonPanelSharedAnimation.texture; + int buttonWidth = width / 4; + int buttonHeight = 100; + int buttonY = height - buttonHeight; + + gameScreen->upgradesButton = createTexturedButton( + buttonTexture, + (Rectangle){0.0, buttonY, buttonWidth, buttonHeight}, + "Upgrades", + WHITE, + BLACK + ); + + gameScreen->achievementsButton = createTexturedButton( + buttonTexture, + (Rectangle){buttonWidth, buttonY, buttonWidth, buttonHeight}, + "Achievements", + WHITE, + BLACK + ); + + gameScreen->rebirthButton = createTexturedButton( + buttonTexture, + (Rectangle){buttonWidth * 2.0, buttonY, buttonWidth, buttonHeight}, + "Rebirth", + WHITE, + BLACK + ); + + gameScreen->statisticsButton = createTexturedButton( + buttonTexture, + (Rectangle){buttonWidth * 3.0, buttonY, buttonWidth, buttonHeight}, + "Statistics", + WHITE, + BLACK + ); } void updateGameScreen(GameScreen* gameScreen, Game* game) @@ -43,9 +86,17 @@ void updateGameScreen(GameScreen* gameScreen, Game* game) // Navigation buttons. updateTexturedButton(&gameScreen->toGameButton); updateTexturedButton(&gameScreen->toEmperorsEmporiumButton); + + // Button panel. + runAnimation(&gameScreen->buttonPanelSharedAnimation); + updateTexturedButton(&gameScreen->upgradesButton); + updateTexturedButton(&gameScreen->achievementsButton); + updateTexturedButton(&gameScreen->rebirthButton); + updateTexturedButton(&gameScreen->statisticsButton); } void closeGameScreen(GameScreen* gameScreen) { + closeAnimation(&gameScreen->buttonPanelSharedAnimation); } -- cgit v1.2.3