Fix hitboxes for entities
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user