From d51a0802aed367f522ebe23e38885d17e1c01bc2 Mon Sep 17 00:00:00 2001 From: hippoz <10706925-hippoz@users.noreply.gitlab.com> Date: Sun, 2 Oct 2022 12:52:49 +0300 Subject: [PATCH] fix fish wandering --- src/main.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main.c b/src/main.c index 710ab7e..56e2d90 100644 --- a/src/main.c +++ b/src/main.c @@ -101,7 +101,7 @@ void fish_update(const struct app *app, struct fish *fish, float delta_time) fish->wander_target_y = rand() % height; fish->wander_start_x = fish->x; fish->wander_start_y = fish->y; - fish->wander_step = 0.1; + fish->wander_step = 0; fish->state = FISH_STATE_WANDER_TRANSITION; } break; @@ -114,8 +114,9 @@ void fish_update(const struct app *app, struct fish *fish, float delta_time) } if (fish->wander_step >= 1.0) { fish->state = FISH_STATE_WANDER_DONE; + break; } - fish->wander_step += 0.05 * delta_time; + fish->wander_step += 0.1 * delta_time; } break; case FISH_STATE_WANDER_DONE: { @@ -207,6 +208,7 @@ void app_loop(struct app *app) { if (event.type == SDL_QUIT) { break; } + prev_ticks = current_ticks; { SDL_Delay(1);