diff options
| author | nathan <nathansmith@disroot.org> | 2025-10-27 12:58:37 +0000 |
|---|---|---|
| committer | nathan <nathansmith@disroot.org> | 2025-10-27 12:58:37 +0000 |
| commit | 95af9c76abef62466dc99cd48fe60d5c8c0677aa (patch) | |
| tree | 016e9b8ca2681603512980bb32b571db6b530e10 /src/player.c | |
| parent | 5925230971875ba3e6e591f0655cf84b739b50fc (diff) | |
| download | FindThings-95af9c76abef62466dc99cd48fe60d5c8c0677aa.tar.gz FindThings-95af9c76abef62466dc99cd48fe60d5c8c0677aa.tar.bz2 FindThings-95af9c76abef62466dc99cd48fe60d5c8c0677aa.zip | |
Working on interaction stuff
Diffstat (limited to 'src/player.c')
| -rw-r--r-- | src/player.c | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/src/player.c b/src/player.c index 4fe468e..f0928e9 100644 --- a/src/player.c +++ b/src/player.c @@ -26,8 +26,7 @@ void updatePlayerHeight(Player* player, Game* game) player->position.y = height; } -// TODO: move magic numbers to settings -void updatePlayer(Player* player, Game* game) +void updatePlayerMovement(Player* player, Game* game) { Camera* camera = &player->camera; Vector2* cameraAngle = &player->cameraAngle; @@ -47,7 +46,7 @@ void updatePlayer(Player* player, Game* game) (Vector3){-cameraAngle->y, cameraAngle->x, 0.0}); player->direction = (Vector3){matrix.m2, matrix.m6, matrix.m10}; - // Player movement. + // Walking around. player->velocity = Vector3Zero(); if (IsKeyDown(settings->forwardKey)) @@ -82,6 +81,17 @@ void updatePlayer(Player* player, Game* game) // Apply camera. camera->position = player->position; camera->target = Vector3Add(player->position, player->direction); +} + +void playerInteractWithEntity(Player* player, Game* game, Entity* entity) +{ + printf("%d\n", interactWithEntity(entity, game, SELECTION_INTERACT)); +} + +// TODO: move magic numbers to settings +void updatePlayer(Player* player, Game* game) +{ + updatePlayerMovement(player, game); Ray ray = (Ray){ .position = player->position, @@ -90,13 +100,15 @@ void updatePlayer(Player* player, Game* game) DrawRay(ray, YELLOW); - int tests; - WorldUID uid = castRayAtWorld(&game->world, ray, false, &tests); - - //printf("%d\n", tests); + WorldUID uid = castRayAtWorld(&game->world, ray, false, NULL); if (uid != -1) { DrawBoundingBox(game->world.entities[uid].box, RED); + + if (IsKeyPressed(game->settings.interactKey)) + { + playerInteractWithEntity(player, game, &game->world.entities[uid]); + } } } |
