diff options
Diffstat (limited to 'src/player.c')
| -rw-r--r-- | src/player.c | 16 |
1 files changed, 9 insertions, 7 deletions
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); |
