diff options
author | nathansmith117 <thenathansmithsmith@gmail.com> | 2024-03-11 18:10:24 +0000 |
---|---|---|
committer | nathansmith117 <thenathansmithsmith@gmail.com> | 2024-03-11 18:10:24 +0000 |
commit | db67be702a0254df3284832f011217a421428bd1 (patch) | |
tree | f8acfa757d88899c330f8c92c6024c9dfd066014 /src | |
parent | bddaf2daaa7f67c2d46a6a611421fc9db6eef83d (diff) | |
download | PenguinYippies-db67be702a0254df3284832f011217a421428bd1.tar.gz PenguinYippies-db67be702a0254df3284832f011217a421428bd1.tar.bz2 PenguinYippies-db67be702a0254df3284832f011217a421428bd1.zip |
More silly shop thingies
Diffstat (limited to 'src')
-rw-r--r-- | src/shop.c | 23 | ||||
-rw-r--r-- | src/shop.h | 4 |
2 files changed, 23 insertions, 4 deletions
@@ -1,11 +1,13 @@ #include "shop.h" #include "game.h" #include "assets.h" +#include "util.h" +#include <raylib.h> // 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); } } @@ -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; |