Fix hitboxes for entities
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
#include "game_state.h"
|
||||
#include "map_layers.h"
|
||||
#include "utils.h"
|
||||
#include "systems/systems.h"
|
||||
|
||||
bool initGameObjectsLayer(BzTileMap *map, BzTileObjectGroup *objectGroup) {
|
||||
Game *game = ecs_singleton_get_mut(ECS, Game);
|
||||
@@ -163,10 +164,12 @@ bool initTreesLayer(BzTileMap *map, BzTileLayer *layer) {
|
||||
f32 sizeY = tileset->tileHeight;
|
||||
f32 posX = layer->offsetX + x * sizeX;
|
||||
f32 posY = layer->offsetY + y * sizeY;
|
||||
posY += sizeY;
|
||||
ecs_entity_t e = entityCreateEmpty();
|
||||
HitBox tHitBox = entityTransformHitBox((Position) {posX, posY}, hb);
|
||||
SpatialGridID gridID = bzSpatialGridInsert(game->entityGrid, &e,
|
||||
posX + hb.x, posY + hb.y,
|
||||
hb.width, hb.height);
|
||||
tHitBox.x, tHitBox.y,
|
||||
tHitBox.width, tHitBox.height);
|
||||
ecs_set(ECS, e, SpatialGridID, {gridID});
|
||||
ecs_set(ECS, e, Position, {posX, posY});
|
||||
ecs_set(ECS, e, Size, {sizeX, sizeY});
|
||||
|
||||
Reference in New Issue
Block a user