diff options
author | nathansmith117 <thenathansmithsmith@gmail.com> | 2024-05-13 19:14:59 +0000 |
---|---|---|
committer | nathansmith117 <thenathansmithsmith@gmail.com> | 2024-05-13 19:14:59 +0000 |
commit | cffca0d01bf99d2eb917f6dc923555ffa0011d88 (patch) | |
tree | dc88c2c5e10c0721d44a2f961da6b93142e5ef5e /src | |
parent | 05b40b9046d7dea6f52872021932bda8855250c4 (diff) | |
download | PenguinYippies-cffca0d01bf99d2eb917f6dc923555ffa0011d88.tar.gz PenguinYippies-cffca0d01bf99d2eb917f6dc923555ffa0011d88.tar.bz2 PenguinYippies-cffca0d01bf99d2eb917f6dc923555ffa0011d88.zip |
Gack working well
Diffstat (limited to 'src')
-rw-r--r-- | src/gack.c | 75 | ||||
-rw-r--r-- | src/gack.h | 5 | ||||
-rw-r--r-- | src/game.c | 2 | ||||
-rw-r--r-- | src/gameScreen.c | 3 |
4 files changed, 82 insertions, 3 deletions
@@ -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) @@ -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); @@ -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]; |