commit 82526cc322aa0596d5d232a90f68eb8f9b135fea parent 95bc3a9627ad32904cfdaf49b1b15c1da825d2d0 Author: amin <dev@aminmesbah.com> Date: Mon, 18 Nov 2019 04:54:25 +0000 Nudge player only over ledges, not under them FossilOrigin-Name: 5d2b4bcf0b6b046874f1bf2a2ade5deff3501b1fb955ee725f96c6adb1d2e9d3 Diffstat:
M | src/game.c | | | 21 | ++++++++++----------- |
1 file changed, 10 insertions(+), 11 deletions(-)
diff --git a/src/game.c b/src/game.c @@ -345,18 +345,17 @@ void game_update_and_render(struct GameMemory *game_memory, struct GameInput *ga } else { - // nudge the player over the ledge - if (player->facing == DIR_RIGHT) + if (player->velocity.y > 0.0f) { - player->velocity.x = 3.0f; - } - else if (player->facing == DIR_LEFT) - { - player->velocity.x = -3.0f; - } - else - { - assert(false); + // nudge the player over the ledge + if (player->facing == DIR_RIGHT) + { + player->velocity.x = 3.0f; + } + else if (player->facing == DIR_LEFT) + { + player->velocity.x = -3.0f; + } } player->acceleration.y = 0.0f; player->velocity.y = 0.0f;