[ADD] begin of collision
This commit is contained in:
@@ -6,4 +6,13 @@ float toolbox_random_float(float a, float b)
|
||||
float diff = b - a;
|
||||
float r = random * diff;
|
||||
return a + r;
|
||||
}
|
||||
|
||||
size_t toolbox_is_collision(float x1, float y1, float width1, float heigth1, float x2, float y2, float width2, float height2)
|
||||
{
|
||||
//TODO make it work
|
||||
return x1 < x2 + width2 / 2 &&
|
||||
x1 + width1 / 2 > x2 &&
|
||||
y1 < y2 + height2 / 2 &&
|
||||
y1 + heigth1 / 2 > y2;
|
||||
}
|
||||
@@ -10,4 +10,19 @@
|
||||
*/
|
||||
float toolbox_random_float(float a, float b);
|
||||
|
||||
/**
|
||||
* @brief checks if a collision has happened between 2 ractancles (bounding boxes)
|
||||
*
|
||||
* @param x1 the center x of the first object
|
||||
* @param y1 the center y of the first object
|
||||
* @param width1 the width of the first object
|
||||
* @param heigth1 the heigth of the first object
|
||||
* @param x2 the center x of the second object
|
||||
* @param y2 the center y of the second object
|
||||
* @param width2 the width of the second object
|
||||
* @param height2 the heigth of the second object
|
||||
* @return size_t 0 if no collision, 1 if there is a collision.
|
||||
*/
|
||||
size_t toolbox_is_collision(float x1, float y1, float width1, float heigth1, float x2, float y2, float width2, float height2);
|
||||
|
||||
#endif // !TOOLBOX_H
|
||||
Reference in New Issue
Block a user