From 1ce1a705c61064e44f83c772b70ee9b208a4c289 Mon Sep 17 00:00:00 2001 From: nathansmith117 Date: Wed, 21 Feb 2024 12:29:29 -0700 Subject: Working on pixal collision thingy --- src/util.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src/util.c') 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; +} -- cgit v1.2.3