aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornathansmith117 <thenathansmithsmith@gmail.com>2024-03-26 17:56:17 +0000
committernathansmith117 <thenathansmithsmith@gmail.com>2024-03-26 17:56:17 +0000
commit0347f1363b12e71518efaf4f54df7c3e348539a5 (patch)
tree4f1b5eadbec02b2763136990de8a32308bc310a6
parent08450f4bc90c77738f0fa35848d35e23ca8c5d63 (diff)
downloadPenguinYippies-0347f1363b12e71518efaf4f54df7c3e348539a5.tar.gz
PenguinYippies-0347f1363b12e71518efaf4f54df7c3e348539a5.tar.bz2
PenguinYippies-0347f1363b12e71518efaf4f54df7c3e348539a5.zip
Added tool bar
-rw-r--r--assets/booperTool.pngbin0 -> 89140 bytes
-rw-r--r--assets/clickerTool.pngbin0 -> 1195 bytes
-rw-r--r--src/assets.c4
-rw-r--r--src/assets.h6
-rw-r--r--src/game.c2
-rw-r--r--src/gameScreen.c62
-rw-r--r--src/gameScreen.h11
7 files changed, 81 insertions, 4 deletions
diff --git a/assets/booperTool.png b/assets/booperTool.png
new file mode 100644
index 0000000..11f50d3
--- /dev/null
+++ b/assets/booperTool.png
Binary files differ
diff --git a/assets/clickerTool.png b/assets/clickerTool.png
new file mode 100644
index 0000000..348e90b
--- /dev/null
+++ b/assets/clickerTool.png
Binary files differ
diff --git a/src/assets.c b/src/assets.c
index a9cd789..6903e48 100644
--- a/src/assets.c
+++ b/src/assets.c
@@ -8,7 +8,9 @@ const char textureAssetsNames[TEXTURE_ASSET_COUNT][ASSETS_NAME_MAX] = {
"toGameIcon.png",
"emperorShopUI.png",
"shopBoard.png",
- "stoneCurrency.png"
+ "stoneCurrency.png",
+ "clickerTool.png",
+ "booperTool.png"
};
const char animationAssetsNames[ANIMATION_ASSET_COUNT][ASSETS_NAME_MAX] = {
diff --git a/src/assets.h b/src/assets.h
index f101e1d..4c0355a 100644
--- a/src/assets.h
+++ b/src/assets.h
@@ -3,7 +3,7 @@
#define ASSETS_NAME_MAX 100
-#define TEXTURE_ASSET_COUNT 7
+#define TEXTURE_ASSET_COUNT 9
#define ANIMATION_ASSET_COUNT 4
#ifndef ASSETS_H
@@ -21,7 +21,9 @@ enum
TO_GAME_ICON_TEXTURE,
EMPEROR_SHOP_UI_TEXTURE,
SHOP_BOARD_TEXTURE,
- STONE_TEXTURE
+ STONE_TEXTURE,
+ CLICKER_TOOL_TEXTURE,
+ BOOPER_TOOL_TEXTURE
};
enum
diff --git a/src/game.c b/src/game.c
index 8177fbd..49fb4f8 100644
--- a/src/game.c
+++ b/src/game.c
@@ -26,7 +26,7 @@ void initGame(Game* game)
game->madeWithUnity = createAnimation(&game->assets.animations[MADE_WITH_UNITY_ANIMATION], 0.2);
game->madeWithUnity.repeat = false;
- playAnimation(&game->madeWithUnity);
+ //playAnimation(&game->madeWithUnity);
}
void updateGame(Game* game)
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)
diff --git a/src/gameScreen.h b/src/gameScreen.h
index e25af53..2b34a05 100644
--- a/src/gameScreen.h
+++ b/src/gameScreen.h
@@ -12,6 +12,13 @@ typedef enum GamePlayPlace {
SHOP_PLACE
} GamePlayPlace;
+typedef enum ToolId {
+ CLICKER_TOOL,
+ BOOPER_TOOL
+} ToolId;
+
+#define TOOL_COUNT 2
+
typedef struct GameScreen {
GamePlayPlace place;
@@ -19,10 +26,14 @@ typedef struct GameScreen {
TexturedButton toEmperorsEmporiumButton;
Shop shop;
+
+ ToolId tool;
} GameScreen;
void initGameScreen(GameScreen* gameScreen, Game* game);
void updateGameScreen(GameScreen* gameScreen, Game* game);
void closeGameScreen(GameScreen* gameScreen);
+void setGameScreenTool(GameScreen* gameScreen, ToolId tool);
+
#endif