a-game

2D platformer written from scratch.
Log | Files | Refs | README | LICENSE

commit e39c05aa093cdef610e327ca3b1f62db11be9d18
parent 2724c1160cc9ae15cbe45893632ad034251d939a
Author: Amin Mesbah <dev@aminmesbah.com>
Date:   Sun, 17 Nov 2019 20:54:25 -0800

Nudge player only over ledges, not under them

Diffstat:
Msrc/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;