Add hitboxes
This commit is contained in:
@@ -11,17 +11,18 @@ ecs_entity_t entityCreateEmpty() {
|
||||
ecs_entity_t entityCreateBaseUnit(const Position position, Player player,
|
||||
EntityType type, AnimType startAnim, Game *game) {
|
||||
BzTileset *tileset = &game->tileset;
|
||||
BzTileID tileID = getEntityTile(type);
|
||||
TextureRegion region = {
|
||||
tileset->tiles,
|
||||
getTextureRect(getEntityTile(type))
|
||||
getTextureRect(tileID)
|
||||
};
|
||||
const Size size = {10.0f * region.rec.width / 16.0f, 10.0f * region.rec.height / 16.0f};
|
||||
HitBox hitbox = getEntityHitBoxRec(tileID);
|
||||
ecs_entity_t e = entityCreateEmpty();
|
||||
ecs_set_ptr(ECS, e, Position, &position);
|
||||
ecs_set_ptr(ECS, e, Size, &size);
|
||||
//ecs_set_ptr(ECS, e, HitBox, &hitbox);
|
||||
BzSpatialGridID spatialID = bzSpatialGridInsert(game->entityGrid, &e,
|
||||
position.x - size.x * 0.5f, position.y - size.y * 0.5f,
|
||||
size.x, size.y);
|
||||
position.x + hitbox.x, position.y + hitbox.y,
|
||||
hitbox.width, hitbox.height);
|
||||
ecs_set(ECS, e, SpatialGridID, { spatialID });
|
||||
ecs_set(ECS, e, Rotation, { 0.0f });
|
||||
ecs_set(ECS, e, Orientation, {0.0f});
|
||||
@@ -78,7 +79,6 @@ ecs_entity_t entityCreateWorker(const Position position, Player player, Game *ga
|
||||
ecs_set_ptr(ECS, e, Arms, &arms);
|
||||
ecs_set(ECS, right, Arm, {.offset = 45.0f, 4.5f});
|
||||
|
||||
ecs_set(ECS, right, Size, {8, 8});
|
||||
ecs_set(ECS, right, Rotation, { 0.0f });
|
||||
TextureRegion daggerRegion = {
|
||||
tileset->tiles,
|
||||
|
||||
Reference in New Issue
Block a user