From 0180e40326f67ef465e1d865a0aed21162e0f5c5 Mon Sep 17 00:00:00 2001 From: nathan Date: Wed, 7 Jan 2026 04:21:32 -0700 Subject: At place thingy --- src/player.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'src/player.c') diff --git a/src/player.c b/src/player.c index df59ffe..fd33524 100644 --- a/src/player.c +++ b/src/player.c @@ -26,6 +26,7 @@ Player createPlayer() .projection = CAMERA_PERSPECTIVE }, .cameraAngle = Vector2Zero(), + .place = ENTITY_NONE, .selectedEntity = ENTITY_NONE, .isInteracting = false }; @@ -59,15 +60,14 @@ void updatePlayerLookingAround(Player* player, Game* game) player->direction = (Vector3){matrix.m2, matrix.m6, matrix.m10}; } -WorldUID playerCheckCollisionWithBuildings(Player* player, Game* game) +WorldUID playerCheckCollisionWithPlace(Player* player, Game* game) { for (int index = 0; index < WORLD_PLACE_COUNT; ++index) { WorldUID uid = game->world.places[index]; Entity* place = &game->world.entities[uid]; - if (entityIsBuilding(place->id) - && CheckCollisionBoxes(place->box, player->box)) + if (CheckCollisionBoxes(place->box, player->box)) { return uid; } @@ -449,12 +449,14 @@ void updatePlayer(Player* player, Game* game) updatePlayerMovement(player, game); - // Check collision with buildings. - WorldUID buildingUID = playerCheckCollisionWithBuildings(player, game); + WorldUID placeUID = playerCheckCollisionWithPlace(player, game); + player->place = placeUID; - if (buildingUID != ENTITY_NONE) + // Collision with buildings. + if (placeUID != ENTITY_NONE && + entityIsBuilding(game->world.entities[placeUID].id)) { - playerHandleCollisionWithBuilding(player, game, buildingUID); + playerHandleCollisionWithBuilding(player, game, placeUID); } playerApplyVelocity(player); -- cgit v1.2.3