Fix hitboxes for entities

This commit is contained in:
2024-01-28 14:09:27 +01:00
parent a61768e912
commit 5d96a02284
11 changed files with 67 additions and 49 deletions

View File

@@ -101,12 +101,8 @@ void entityUpdateSpatialID(ecs_iter_t *it) {
BZ_UNUSED(velocity);
for (i32 i = 0; i < it->count; i++) {
Rectangle rec = {
position[i].x + hitbox[i].x,
position[i].y + hitbox[i].y,
hitbox[i].width, hitbox[i].height
};
bzSpatialGridUpdate(game->entityGrid, id[i], rec.x, rec.y, rec.width, rec.height);
HitBox hb = entityTransformHitBox(position[i], hitbox[i]);
bzSpatialGridUpdate(game->entityGrid, id[i], hb.x, hb.y, hb.width, hb.height);
}
}
@@ -227,9 +223,7 @@ void renderColliders(ecs_iter_t *it) {
HitBox *hitbox = ecs_field(it, HitBox , 2);
for (i32 i = 0; i < it->count; i++) {
HitBox hb = hitbox[i];
hb.x += pos[i].x;
hb.y += pos[i].y;
HitBox hb = entityTransformHitBox(pos[i], hitbox[i]);
DrawRectangleLinesEx(hb, 1.0f, RED);
}
}