From 8372a776ad2e06b99e4704403504ba74932276ec Mon Sep 17 00:00:00 2001 From: nathansmith117 Date: Wed, 13 Mar 2024 12:07:43 -0600 Subject: Made a clicker --- src/shop.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'src/shop.c') diff --git a/src/shop.c b/src/shop.c index 465bd7a..47f3b7b 100644 --- a/src/shop.c +++ b/src/shop.c @@ -3,6 +3,7 @@ #include "assets.h" #include "util.h" #include "clicky.h" +#include // 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); } -- cgit v1.2.3