aboutsummaryrefslogtreecommitdiffstats
path: root/src/player.c
diff options
context:
space:
mode:
authornathan <nathansmith@disroot.org>2025-07-06 21:38:08 +0000
committernathan <nathansmith@disroot.org>2025-07-06 21:38:08 +0000
commit811d5bf064ce992bc742f55c112a777801126861 (patch)
tree5842fa0f76b2b0dbd4a04ac7a237b4d5753fdd1d /src/player.c
parent1abde5cdf85269597b180d5e88e9d62798fc893c (diff)
downloadFindThings-811d5bf064ce992bc742f55c112a777801126861.tar.gz
FindThings-811d5bf064ce992bc742f55c112a777801126861.tar.bz2
FindThings-811d5bf064ce992bc742f55c112a777801126861.zip
Finally smooth walking
Diffstat (limited to 'src/player.c')
-rw-r--r--src/player.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/player.c b/src/player.c
index 0342040..9c66627 100644
--- a/src/player.c
+++ b/src/player.c
@@ -18,6 +18,14 @@ Player createPlayer()
};
}
+// Fake physics, distance from ground.
+void updatePlayerHeight(Player* player, Game* game)
+{
+ float height = getWorldHeightAtLocation(
+ game->world, player->position.x, player->position.z) + PLAYER_HEIGHT;
+ player->position.y = height;
+}
+
// TODO: move magic numbers to settings
void updatePlayer(Player* player, Game* game)
{
@@ -65,14 +73,13 @@ void updatePlayer(Player* player, Game* game)
player->velocity = Vector3Scale(player->velocity, 10.0);
- // Apply velocity
+ // Apply velocity.
player->position = Vector3Add(
player->position, Vector3Scale(player->velocity, GetFrameTime()));
+
+ updatePlayerHeight(player, game);
// Apply camera.
camera->position = player->position;
camera->target = Vector3Add(player->position, player->direction);
-
- player->position.y = getWorldHeightAtLocation(
- game->world, player->position.x, player->position.z) + PLAYER_HEIGHT;
}