From 1562dd67d16d328e919db28cfd48206c8c868fe4 Mon Sep 17 00:00:00 2001 From: BoredGuy Date: Sun, 31 Aug 2025 19:24:24 +0300 Subject: Added hitbox/hurtbox system - Made the entity struct much smaller --- include/utils.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'include/utils.h') diff --git a/include/utils.h b/include/utils.h index 5a4a4ac..cb1770e 100644 --- a/include/utils.h +++ b/include/utils.h @@ -60,4 +60,21 @@ static inline Rectangle GetCurrentSourceRectangle(const Animation* animation) { return animation->srcRects[animation->currentFrame]; } +static inline Rectangle GetEntityHitboxGlobal(const Entity* e, int hbIndex) { + Rectangle hitBoxGlobal = e->hitBoxes[hbIndex]; + hitBoxGlobal.x += e->position.x; + hitBoxGlobal.y += e->position.y; + + return hitBoxGlobal; +} + +static inline Rectangle GetEntityHurtboxGlobal(const Entity* e, int hbIndex) { + Rectangle hurtBoxGlobal = e->hurtBoxes[hbIndex]; + hurtBoxGlobal.x += e->position.x; + hurtBoxGlobal.y += e->position.y; + + return hurtBoxGlobal; +} + + #endif // UTILS_H_ -- cgit v1.2.3