aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornathansmith117 <thenathansmithsmith@gmail.com>2024-02-21 03:18:32 +0000
committernathansmith117 <thenathansmithsmith@gmail.com>2024-02-21 03:18:32 +0000
commit8ff25c1e8951304ff5c125e05a8fa044a198ef72 (patch)
treeae902e210d2f1f8a556ad7d1a7f885e393d9afe1
parent6c63c3d327cf3b494309db82bdd4489b59d3d247 (diff)
downloadPenguinYippies-8ff25c1e8951304ff5c125e05a8fa044a198ef72.tar.gz
PenguinYippies-8ff25c1e8951304ff5c125e05a8fa044a198ef72.tar.bz2
PenguinYippies-8ff25c1e8951304ff5c125e05a8fa044a198ef72.zip
More buttons
-rw-r--r--src/gameScreen.c37
-rw-r--r--src/gameScreen.h17
-rw-r--r--src/ui.c35
3 files changed, 72 insertions, 17 deletions
diff --git a/src/gameScreen.c b/src/gameScreen.c
index bfdbf6e..1af0faf 100644
--- a/src/gameScreen.c
+++ b/src/gameScreen.c
@@ -3,11 +3,46 @@
void initGameScreen(GameScreen* gameScreen, Game* game)
{
+ int width = GetScreenWidth();
+ int height = GetScreenHeight();
+ int navigationButtonSize = 100;
+ int navigationButtonX = width - navigationButtonSize - 5.0;
+
+ // Navigation buttons.
+ gameScreen->toGameButton = createTexturedButton(
+ &game->assets.textures[TO_GAME_ICON_TEXTURE],
+ (Rectangle){navigationButtonX, 5.0, navigationButtonSize, navigationButtonSize},
+ "",
+ WHITE,
+ BLACK
+ );
+
+ gameScreen->toEmperorsEmporiumButton = createTexturedButton(
+ &game->assets.textures[TO_EMPERORS_EMPORIUM_ICON_TEXTURE],
+ (Rectangle){navigationButtonX, navigationButtonSize + 15.0, navigationButtonSize, navigationButtonSize},
+ "",
+ WHITE,
+ BLACK
+ );
}
void updateGameScreen(GameScreen* gameScreen, Game* game)
{
- ClearBackground(RAYWHITE);
+ // Draw background.
+ Texture background = game->assets.textures[MAIN_SCREEN_BACKGROUND_TEXTURE];
+
+ DrawTexturePro(
+ background,
+ (Rectangle){0.0, 0.0, background.width, background.height},
+ (Rectangle){0.0, 0.0, GetScreenWidth(), GetScreenHeight()},
+ (Vector2){0.0, 0.0},
+ 0.0,
+ WHITE
+ );
+
+ // Navigation buttons.
+ updateTexturedButton(&gameScreen->toGameButton);
+ updateTexturedButton(&gameScreen->toEmperorsEmporiumButton);
}
void closeGameScreen(GameScreen* gameScreen)
diff --git a/src/gameScreen.h b/src/gameScreen.h
index 9b4191e..f911edd 100644
--- a/src/gameScreen.h
+++ b/src/gameScreen.h
@@ -1,9 +1,26 @@
#include "gameCommon.h"
+#include "animation.h"
+#include "ui.h"
#ifndef GAME_SCREEN_H
#define GAME_SCREEN_H
typedef struct GameScreen {
+ TexturedButton toGameButton;
+ TexturedButton toEmperorsEmporiumButton;
+
+ // The little button panel at the bottem.
+ Animation updateButtonAnimation;
+ TexturedButton updateButton;
+
+ Animation achievementsButtonAnimation;
+ TexturedButton achievementsButton;
+
+ Animation rebirthButtonAnimation;
+ TexturedButton rebirthButton;
+
+ Animation statisticsButtonAnimation;
+ TexturedButton statisticsButton;
} GameScreen;
void initGameScreen(GameScreen* gameScreen, Game* game);
diff --git a/src/ui.c b/src/ui.c
index 7166add..f07dc96 100644
--- a/src/ui.c
+++ b/src/ui.c
@@ -31,28 +31,31 @@ bool updateTexturedButton(TexturedButton* button)
button->backgroundColor
);
-
- // Draw outline thingy.
- if (IsMouseButtonDown(MOUSE_LEFT_BUTTON))
+ // Draw text centered in button if we have a message.
+ if (button->message[0] != '\0')
{
- DrawRectangleLinesEx(button->rect, 2, button->foregroundColor);
+ DrawText(
+ button->message,
+ button->rect.x + (button->rect.width / 2.0 - (button->messageLength * button->fontSize / 4.0)),
+ button->rect.y + (button->rect.height / 2.0 - button->fontSize / 2.0),
+ button->fontSize,
+ button->foregroundColor
+ );
}
- // Draw text centered in button.
- DrawText(
- button->message,
- button->rect.x + (button->rect.width / 2.0 - (button->messageLength * button->fontSize / 4.0)),
- button->rect.y + (button->rect.height / 2.0 - button->fontSize / 2.0),
- button->fontSize,
- button->foregroundColor
- );
-
button->isPressed = false;
- // Check if the button is clicked.
- if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON))
+ // Outline and detect click stuff.
+ if (CheckCollisionPointRec(GetMousePosition(), button->rect))
{
- if (CheckCollisionPointRec(GetMousePosition(), button->rect))
+ // Draw outline thingy.
+ if (IsMouseButtonDown(MOUSE_LEFT_BUTTON))
+ {
+ DrawRectangleLinesEx(button->rect, 2, button->foregroundColor);
+ }
+
+ // Is clicked.
+ if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON))
{
button->isPressed = true;
}