aboutsummaryrefslogtreecommitdiffstats
path: root/src/player.c
diff options
context:
space:
mode:
authornathan <nathansmith@disroot.org>2026-01-07 11:21:32 +0000
committernathan <nathansmith@disroot.org>2026-01-07 11:21:32 +0000
commit0180e40326f67ef465e1d865a0aed21162e0f5c5 (patch)
tree2f72f94010920b0d9d9147620ed205f642720e3e /src/player.c
parent0fb94d28d3f64e95ff228edbfd8fc17d420e215f (diff)
downloadFindThings-0180e40326f67ef465e1d865a0aed21162e0f5c5.tar.gz
FindThings-0180e40326f67ef465e1d865a0aed21162e0f5c5.tar.bz2
FindThings-0180e40326f67ef465e1d865a0aed21162e0f5c5.zip
At place thingy
Diffstat (limited to 'src/player.c')
-rw-r--r--src/player.c16
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);