summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorBoredGuy <osome3717@gmail.com>2025-08-31 19:24:24 +0300
committerBoredGuy <osome3717@gmail.com>2025-08-31 19:24:24 +0300
commit1562dd67d16d328e919db28cfd48206c8c868fe4 (patch)
treefe8f78e9d94ae55ff3868739dc359dd4629f8441 /include
parent8a7c25827624348ccd7a9ac8bf978e71117f8b75 (diff)
Added hitbox/hurtbox system
- Made the entity struct much smaller
Diffstat (limited to 'include')
-rw-r--r--include/barrel_data.h2
-rw-r--r--include/constants.h5
-rw-r--r--include/physics.h2
-rw-r--r--include/utils.h17
4 files changed, 23 insertions, 3 deletions
diff --git a/include/barrel_data.h b/include/barrel_data.h
index 0db5fdd..97a13db 100644
--- a/include/barrel_data.h
+++ b/include/barrel_data.h
@@ -4,7 +4,7 @@ static const Rectangle physicsCollider = (Rectangle) {
.x = NO_OFFSET,
.y = NO_OFFSET,
.width = 100,
- .height = 100
+ .height = 120
};
static const Rectangle destRect = (Rectangle) {
diff --git a/include/constants.h b/include/constants.h
index 2fd6ace..a2ea961 100644
--- a/include/constants.h
+++ b/include/constants.h
@@ -3,7 +3,7 @@
#define WINDOW_WIDTH 1280
#define WINDOW_HEIGHT 720
-#define MAX_ENTITY_COUNT 2048
+#define MAX_ENTITY_COUNT 128
#define MAX_AREA_COUNT 4
#define MAX_SPRITE_COUNT 4 //Maximum number of sprites per entity
@@ -12,3 +12,6 @@
#define MAX_FRAMES 30
#define MAX_ANIMATIONS 20
+
+#define FPS_POS_X 10
+#define FPS_POS_Y 10
diff --git a/include/physics.h b/include/physics.h
index b393d08..8c50fb4 100644
--- a/include/physics.h
+++ b/include/physics.h
@@ -2,4 +2,4 @@
#include "game.h"
-void MoveAndSlide(Entity* e, float dt); \ No newline at end of file
+void MoveAndSlide(Entity* e, float dt);
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_