blob: 819a9568a19ef911a7a9c28731329f63277fe153 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
#include "util.h"
#include "game.h"
Vector2 getScaledMousePosition()
{
Vector2 mousePosition = GetMousePosition();
mousePosition.x *= (float)WINDOW_WIDTH / GetScreenWidth();
mousePosition.y *= (float)WINDOW_HEIGHT / GetScreenHeight();
return mousePosition;
}
bool doesCollideWithAnimationData(Rectangle rect, void* data, int width, int height, int frame, Vector2 point)
{
// Doesn't collide with rect.
if (!CheckCollisionPointRec(point, rect))
{
return false;
}
float xScale = (float)width / rect.width;
float yScale = (float)height / rect.height;
int row = (point.y - rect.y) * yScale;
int col = (point.x - rect.x) * xScale;
unsigned int frameOffset = width * height * frame;
// Position of the apha byte in the color.
unsigned int position = (frameOffset + (width * row + col)) * 4 + 3;
// Check apha at position.
if (*(((unsigned char*)data) + position) != 0x00)
{
return true;
}
return false;
}
|