aboutsummaryrefslogtreecommitdiffstats
path: root/src/util.c
diff options
context:
space:
mode:
authornathansmith117 <thenathansmithsmith@gmail.com>2024-02-21 19:29:29 +0000
committernathansmith117 <thenathansmithsmith@gmail.com>2024-02-21 19:29:29 +0000
commit1ce1a705c61064e44f83c772b70ee9b208a4c289 (patch)
treef5e593fc4ea11a2a3dd3a186679421086af4a01e /src/util.c
parent1a677439d001e9ef481c6e932b6ca78c3733f531 (diff)
downloadPenguinYippies-1ce1a705c61064e44f83c772b70ee9b208a4c289.tar.gz
PenguinYippies-1ce1a705c61064e44f83c772b70ee9b208a4c289.tar.bz2
PenguinYippies-1ce1a705c61064e44f83c772b70ee9b208a4c289.zip
Working on pixal collision thingy
Diffstat (limited to 'src/util.c')
-rw-r--r--src/util.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/util.c b/src/util.c
index 308343c..864fab6 100644
--- a/src/util.c
+++ b/src/util.c
@@ -9,3 +9,26 @@ Vector2 getScaledMousePosition()
return mousePosition;
}
+
+bool doesCollideWithAnimation(Rectangle rect, Animation* animation, Vector2 point)
+{
+ float xScale = (float)rect.width / animation->width;
+ float yScale = (float)rect.height / animation->height;
+
+ unsigned int frameOffset = animation->width * animation->height * 4 * animation->currentFrame;
+
+ // Check each pixal.
+ for (int row = 0; row < rect.height; ++row)
+ {
+ for (int col = 0; col < rect.width; ++col)
+ {
+ int scaledRow = row * yScale;
+ int scaledCol = col * xScale;
+
+ int pixalPosition = frameOffset + (animation->width * scaledRow + scaledCol);
+
+ }
+ }
+
+ return false;
+}