diff options
Diffstat (limited to 'src/player.c')
-rw-r--r-- | src/player.c | 15 |
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; } |