aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authornathansmith117 <thenathansmithsmith@gmail.com>2024-03-11 18:10:24 +0000
committernathansmith117 <thenathansmithsmith@gmail.com>2024-03-11 18:10:24 +0000
commitdb67be702a0254df3284832f011217a421428bd1 (patch)
treef8acfa757d88899c330f8c92c6024c9dfd066014 /src
parentbddaf2daaa7f67c2d46a6a611421fc9db6eef83d (diff)
downloadPenguinYippies-db67be702a0254df3284832f011217a421428bd1.tar.gz
PenguinYippies-db67be702a0254df3284832f011217a421428bd1.tar.bz2
PenguinYippies-db67be702a0254df3284832f011217a421428bd1.zip
More silly shop thingies
Diffstat (limited to 'src')
-rw-r--r--src/shop.c23
-rw-r--r--src/shop.h4
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 <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);
}
}
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;