aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authornathansmith117 <thenathansmithsmith@gmail.com>2024-05-13 19:14:59 +0000
committernathansmith117 <thenathansmithsmith@gmail.com>2024-05-13 19:14:59 +0000
commitcffca0d01bf99d2eb917f6dc923555ffa0011d88 (patch)
treedc88c2c5e10c0721d44a2f961da6b93142e5ef5e /src
parent05b40b9046d7dea6f52872021932bda8855250c4 (diff)
downloadPenguinYippies-cffca0d01bf99d2eb917f6dc923555ffa0011d88.tar.gz
PenguinYippies-cffca0d01bf99d2eb917f6dc923555ffa0011d88.tar.bz2
PenguinYippies-cffca0d01bf99d2eb917f6dc923555ffa0011d88.zip
Gack working well
Diffstat (limited to 'src')
-rw-r--r--src/gack.c75
-rw-r--r--src/gack.h5
-rw-r--r--src/game.c2
-rw-r--r--src/gameScreen.c3
4 files changed, 82 insertions, 3 deletions
diff --git a/src/gack.c b/src/gack.c
index 24debb1..ca62e0c 100644
--- a/src/gack.c
+++ b/src/gack.c
@@ -1,13 +1,30 @@
#include "gack.h"
#include "game.h"
#include "assets.h"
+#include "util.h"
+#include "clicky.h"
+
+void increasePenguinLolStonesPerClick(GackEntry* entry, Game* game)
+{
+ ++game->clickies.settings.penguinLolStonesPerClick;
+ entry->cost *= 1.5;
+}
+
+void decreaseClickerDelay(GackEntry* entry, Game* game)
+{
+ game->clickies.settings.clickersDelay /= 1.5;
+ entry->cost *= 1.5;
+}
void initGack(Gack* gack)
{
+ gack->entries[0] = (GackEntry){"Increase penguin lol stones per click", 100, increasePenguinLolStonesPerClick};
+ gack->entries[1] = (GackEntry){"Decrease clicker delay", 200, decreaseClickerDelay};
}
void updateGack(Gack* gack, Game* game)
{
+ // Draw gack background.
Texture gackTexture = game->assets.textures[GACK_PENGUIN_TEXTURE];
DrawTexturePro(
@@ -18,6 +35,64 @@ void updateGack(Gack* gack, Game* game)
0.0,
WHITE
);
+
+ int entryWidth = 500;
+ int entryHeight = 50;
+ int startX = 20;
+ int startY = 70;
+
+ // Update each entry.
+ for (int i = 0; i < GACK_ENTRY_COUNT; ++i)
+ {
+ GackEntry* entry = &gack->entries[i];
+
+ int yPosition = startY + (entryHeight * i);
+
+ Rectangle rect = (Rectangle){
+ startX,
+ yPosition,
+ entryWidth,
+ entryHeight
+ };
+
+ Color outlineColor = BLACK;
+
+ // Is clicked
+ if (CheckCollisionPointRec(getScaledMousePosition(), rect))
+ {
+ // Clicked on it to buy.
+ if (game->stones >= entry->cost && IsMouseButtonPressed(MOUSE_LEFT_BUTTON))
+ {
+ game->stones -= entry->cost;
+
+ if (entry->callback != NULL)
+ {
+ entry->callback(entry, game);
+ }
+ }
+
+ if (IsMouseButtonDown(MOUSE_LEFT_BUTTON))
+ {
+ outlineColor = PINK;
+ }
+ }
+
+ // Draw this stupid thing.
+ DrawRectangleLinesEx(rect, 2.0, outlineColor);
+ DrawText(entry->description, startX + 5, yPosition + 5, 20, BLACK);
+
+ // Draw cost.
+ Color costColor = BLACK;
+
+ if (entry->cost > game->stones)
+ {
+ costColor = RED;
+ }
+
+ char costBuf[10];
+ snprintf(costBuf, sizeof(costBuf), "%d", entry->cost);
+ DrawText(costBuf, startX + rect.width + 5, yPosition + 5, 40, costColor);
+ }
}
void closeGack(Gack* gack)
diff --git a/src/gack.h b/src/gack.h
index fc1ed86..1bb4382 100644
--- a/src/gack.h
+++ b/src/gack.h
@@ -4,17 +4,20 @@
#define GACK_H
#define GACK_NAME_MAX 256
+#define GACK_ENTRY_COUNT 2
typedef struct GackEntry GackEntry;
typedef void (*GackEntryCB)(GackEntry* entry, Game* game);
+// A entry for a upgrade.
typedef struct GackEntry {
- char description;
+ char description[GACK_NAME_MAX];
int cost;
GackEntryCB callback;
} GackEntry;
typedef struct Gack {
+ GackEntry entries[GACK_ENTRY_COUNT];
} Gack;
void initGack(Gack* gack);
diff --git a/src/game.c b/src/game.c
index 6f74c58..df8a57b 100644
--- a/src/game.c
+++ b/src/game.c
@@ -29,7 +29,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 a6e9355..bbe5a65 100644
--- a/src/gameScreen.c
+++ b/src/gameScreen.c
@@ -44,6 +44,7 @@ void initGameScreen(GameScreen* gameScreen, Game* game)
gameScreen->nextShootingStoneCount = RUN_SHOOTER_GAME_COUNT_START;
initShop(&gameScreen->shop, game);
+ initGack(&gameScreen->gack);
setGameScreenTool(gameScreen, CLICKER_TOOL);
}
@@ -227,7 +228,7 @@ void updateGameScreen(GameScreen* gameScreen, Game* game)
{
++game->stones;
enterShooterScreen(game);
- gameScreen->nextShootingStoneCount *= 2.5;
+ gameScreen->nextShootingStoneCount *= 5.0;
}
char nextShooterBuf[60];