diff options
| author | citrons <citrons@mondecitronne.com> | 2023-10-17 18:44:33 -0500 |
|---|---|---|
| committer | citrons <citrons@mondecitronne.com> | 2023-10-17 18:44:33 -0500 |
| commit | 31530c9b9da7a579406633792507177c9435c5eb (patch) | |
| tree | 41e346b32292482ff127ab0da2534a7f65fbff60 /world.c | |
| parent | 7c5f7142f76ca1be5eaf3f7795f18f8451aa30d5 (diff) | |
stamina based on # of movements rather than time
Diffstat (limited to 'world.c')
| -rw-r--r-- | world.c | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -128,8 +128,7 @@ SDL_bool is_solid(tile t) { } SDL_bool player_grounded(world *w) { - if (SDL_TICKS_PASSED(SDL_GetTicks(), w->player.stamina_time)) - return SDL_FALSE; + if (w->player.stamina <= 0) return SDL_FALSE; SDL_bool grounded = SDL_FALSE; for (int y = w->player.pos.y; y < w->player.pos.y + 2; y++) { for (int x = w->player.pos.x - 1; x < w->player.pos.x + 2; x++) @@ -142,6 +141,8 @@ void player_walk(world *w, int x, int y) { if (!SDL_TICKS_PASSED(SDL_GetTicks(), w->player.walk_wait)) return; + if (w->player.stamina > 0) w->player.stamina--; + if (x != 0 || y != 0) { SDL_Point new_pos = w->player.pos; new_pos.x += x; @@ -315,7 +316,7 @@ void tick_world(world *w) { tile below = get_tile(w, (SDL_Point) {w->player.pos.x, w->player.pos.y + 1}); if (is_solid(below)) - w->player.stamina_time = SDL_GetTicks() + PLAYER_STAMINA; + w->player.stamina = PLAYER_STAMINA; if (!player_grounded(w)) { if (SDL_TICKS_PASSED(SDL_GetTicks(), w->player.gravity_time)) { |
