From db67be702a0254df3284832f011217a421428bd1 Mon Sep 17 00:00:00 2001 From: nathansmith117 Date: Mon, 11 Mar 2024 12:10:24 -0600 Subject: More silly shop thingies --- src/shop.c | 23 ++++++++++++++++++++--- src/shop.h | 4 +++- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/shop.c b/src/shop.c index 3b77f09..f1b6493 100644 --- a/src/shop.c +++ b/src/shop.c @@ -1,11 +1,13 @@ #include "shop.h" #include "game.h" #include "assets.h" +#include "util.h" +#include // Callbacks. -void createPenguinLolCB(Game* game) +void createPenguinLolCB(ShopEntry* entry, Game* game) { - + puts("hihihi"); } void initShop(Shop* shop, Game* game) @@ -67,7 +69,22 @@ void updateShop(Shop* shop, Game* game) WHITE ); - DrawRectangleLinesEx(rects[i], 2, BLACK); + Color outlineColor = BLACK; + + // Test collision. + if (CheckCollisionPointRec(getScaledMousePosition(), rects[i])) + { + if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) + { + shop->entries[i].callback(&shop->entries[i], game); + } + else if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) + { + outlineColor = BLUE; + } + } + + DrawRectangleLinesEx(rects[i], 2, outlineColor); } } diff --git a/src/shop.h b/src/shop.h index e9555a5..efbca6b 100644 --- a/src/shop.h +++ b/src/shop.h @@ -7,7 +7,9 @@ #ifndef SHOP_H #define SHOP_H -typedef void (*ShopyEntryCB)(Game* game); +typedef struct ShopEntry ShopEntry; + +typedef void (*ShopyEntryCB)(ShopEntry* entry, Game* game); typedef struct ShopEntry { Texture* texture; -- cgit v1.2.3