diff options
author | nathansmith117 <thenathansmithsmith@gmail.com> | 2024-03-13 18:07:43 +0000 |
---|---|---|
committer | nathansmith117 <thenathansmithsmith@gmail.com> | 2024-03-13 18:07:43 +0000 |
commit | 8372a776ad2e06b99e4704403504ba74932276ec (patch) | |
tree | 1c688217d8420474ad4c8b68c721d1a27d9df43d /src/shop.c | |
parent | 694efe00e1e01af8534672b60970a3e0555e5f34 (diff) | |
download | PenguinYippies-8372a776ad2e06b99e4704403504ba74932276ec.tar.gz PenguinYippies-8372a776ad2e06b99e4704403504ba74932276ec.tar.bz2 PenguinYippies-8372a776ad2e06b99e4704403504ba74932276ec.zip |
Made a clicker
Diffstat (limited to 'src/shop.c')
-rw-r--r-- | src/shop.c | 20 |
1 files changed, 19 insertions, 1 deletions
@@ -3,6 +3,7 @@ #include "assets.h" #include "util.h" #include "clicky.h" +#include <raylib.h> // Callbacks. void createPenguinLolCB(ShopEntry* entry, Game* game) @@ -19,6 +20,18 @@ void createPenguinLolCB(ShopEntry* entry, Game* game) addClickyToClickies(&game->clickies, lol); } +void createClicker(ShopEntry* entry, Game* game) +{ + SetRandomSeed(clock()); + + int randomX = GetRandomValue(200, WINDOW_WIDTH - 200); + int randomY = GetRandomValue(200, WINDOW_HEIGHT - 200); + + Clicky clicker = createClickerClicky(game); + + addClickyToClickies(&game->clickies, clicker); +} + void initShop(Shop* shop, Game* game) { Assets* assets = &game->assets; @@ -26,6 +39,9 @@ void initShop(Shop* shop, Game* game) // Entries. shop->penguinLol = LoadTextureFromImage(assets->animations[PENGUIN_LOL_ANIMATION].image); shop->entries[0] = (ShopEntry){&shop->penguinLol, 10, createPenguinLolCB}; + + shop->clicker = LoadTextureFromImage(assets->animations[CLICKER_ANIMATION].image); + shop->entries[1] = (ShopEntry){&shop->clicker, 20, createClicker}; } void buyThingFromShop(Shop* shop, int id, Game* game) @@ -72,7 +88,8 @@ void updateShop(Shop* shop, Game* game) double height = 100.0; Rectangle rects[SHOP_ENTRY_COUNT] = { - (Rectangle){startX, startY, width, height} + (Rectangle){startX, startY, width, height}, + (Rectangle){startX, startY + height, width, height} }; // Entries. @@ -111,4 +128,5 @@ void updateShop(Shop* shop, Game* game) void closeShop(Shop* shop) { UnloadTexture(shop->penguinLol); + UnloadTexture(shop->clicker); } |