updated rect class and added some documentation

This commit is contained in:
herbglitch 2023-06-23 23:07:39 -06:00
parent 2b02bf9d2e
commit 3565a5cf15
3 changed files with 74 additions and 0 deletions

View file

@ -3,6 +3,25 @@
//VERY TEMP
// #include <SDL.h>
void ARC_Rect_CenterOn(ARC_Rect *rect, ARC_Rect *bounds){
rect->x = ((bounds->x + bounds->w) / 2) - (rect->w / 2);
rect->y = ((bounds->y + bounds->h) / 2) - (rect->h / 2);
}
void ARC_FRect_CenterOn(ARC_FRect *rect, ARC_FRect *bounds){
rect->x = ((bounds->x + bounds->w) / 2.0f) - (rect->w / 2.0f);
rect->y = ((bounds->y + bounds->h) / 2.0f) - (rect->h / 2.0f);
}
ARC_Rect ARC_FRect_CastToRect(ARC_FRect *rect){
return (ARC_Rect){
.x = (int32_t)rect->x,
.y = (int32_t)rect->y,
.w = (int32_t)rect->w,
.h = (int32_t)rect->h,
};
}
int32_t ARC_Rect_Intersects(ARC_Rect *rect1, ARC_Rect *rect2){
if(rect1->x <= rect2->x + rect2->w && rect1->x + rect1->w >= rect2->x &&
rect1->y <= rect2->y + rect2->h && rect1->y + rect1->h >= rect2->y){