diff options
Diffstat (limited to 'src/util.c')
-rw-r--r-- | src/util.c | 23 |
1 files changed, 23 insertions, 0 deletions
@@ -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; +} |