Extract collision detection into a ui module

This commit is contained in:
Abdelrahman Said 2024-01-15 22:35:31 +00:00
parent d114cfce99
commit c831fd23f7
2 changed files with 16 additions and 0 deletions

10
include/ui.h Normal file
View File

@ -0,0 +1,10 @@
#ifndef UI_H
#define UI_H
#include "aliases/aliases.h"
#include "window.h"
#include <stdbool.h>
bool aabb(const rect_t *rect, i32 x, i32 y);
#endif // !UI_H

6
src/ui.c Normal file
View File

@ -0,0 +1,6 @@
#include "ui.h"
bool aabb(const rect_t *rect, i32 x, i32 y) {
return x > rect->topleft.x && x <= rect->topleft.x + rect->w &&
y > rect->topleft.y && y <= rect->topleft.y + rect->h;
}