diff options
author | nathansmith117 <thenathansmithsmith@gmail.com> | 2024-03-26 17:56:17 +0000 |
---|---|---|
committer | nathansmith117 <thenathansmithsmith@gmail.com> | 2024-03-26 17:56:17 +0000 |
commit | 0347f1363b12e71518efaf4f54df7c3e348539a5 (patch) | |
tree | 4f1b5eadbec02b2763136990de8a32308bc310a6 /src/gameScreen.c | |
parent | 08450f4bc90c77738f0fa35848d35e23ca8c5d63 (diff) | |
download | PenguinYippies-0347f1363b12e71518efaf4f54df7c3e348539a5.tar.gz PenguinYippies-0347f1363b12e71518efaf4f54df7c3e348539a5.tar.bz2 PenguinYippies-0347f1363b12e71518efaf4f54df7c3e348539a5.zip |
Added tool bar
Diffstat (limited to 'src/gameScreen.c')
-rw-r--r-- | src/gameScreen.c | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/src/gameScreen.c b/src/gameScreen.c index 6d772f1..53fc1bc 100644 --- a/src/gameScreen.c +++ b/src/gameScreen.c @@ -1,6 +1,7 @@ #include "gameScreen.h" #include "game.h" #include "assets.h" +#include "util.h" #include <raylib.h> void initGameScreen(GameScreen* gameScreen, Game* game) @@ -31,6 +32,8 @@ void initGameScreen(GameScreen* gameScreen, Game* game) ); initShop(&gameScreen->shop, game); + + setGameScreenTool(gameScreen, CLICKER_TOOL); } void updateGameScreenClickyDesktop(GameScreen* gameScreen, Game* game) @@ -52,6 +55,64 @@ void updateGameScreenNavigation(GameScreen* gameScreen, Game* game) } } +void setGameScreenTool(GameScreen* gameScreen, ToolId tool) +{ + gameScreen->tool = tool; + + // TODO: Switch cursor for different tools + switch (tool) + { + case CLICKER_TOOL: + break; + case BOOPER_TOOL: + break; + default: + break; + } +} + +void updateGameScreenToolBar(GameScreen* gameScreen, Game* game) +{ + int toolIconWidth = 50; + int toolIconHeight = 50; + + Assets* assets = &game->assets; + + Texture toolTextures[TOOL_COUNT] = { + assets->textures[CLICKER_TOOL_TEXTURE], + assets->textures[BOOPER_TOOL_TEXTURE] + }; + + for (int i = 0; i < TOOL_COUNT; ++i) + { + Rectangle rect = (Rectangle){i * toolIconWidth + 200, 0.0, toolIconWidth, toolIconHeight}; + Texture texture = toolTextures[i]; + + // Draw tool texture. + DrawTexturePro( + texture, + (Rectangle){0.0, 0.0, texture.width, texture.height}, + rect, + (Vector2){0.0, 0.0}, + 0.0, + WHITE + ); + + // Outline current tool + if (i == gameScreen->tool) + { + DrawRectangleLinesEx(rect, 3, BLACK); + } + else // Switch tools. + { + if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT) && CheckCollisionPointRec(getScaledMousePosition(), rect)) + { + setGameScreenTool(gameScreen, i); + } + } + } +} + void updateGameScreen(GameScreen* gameScreen, Game* game) { // Draw background. @@ -96,6 +157,7 @@ void updateGameScreen(GameScreen* gameScreen, Game* game) DrawText(stonesBuf, 40.0, 5.0, 30, BLACK); updateGameScreenNavigation(gameScreen, game); + updateGameScreenToolBar(gameScreen, game); } void closeGameScreen(GameScreen* gameScreen) |