fix fish wandering
This commit is contained in:
parent
553678b169
commit
d51a0802ae
1 changed files with 4 additions and 2 deletions
|
@ -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_target_y = rand() % height;
|
||||||
fish->wander_start_x = fish->x;
|
fish->wander_start_x = fish->x;
|
||||||
fish->wander_start_y = fish->y;
|
fish->wander_start_y = fish->y;
|
||||||
fish->wander_step = 0.1;
|
fish->wander_step = 0;
|
||||||
fish->state = FISH_STATE_WANDER_TRANSITION;
|
fish->state = FISH_STATE_WANDER_TRANSITION;
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
|
@ -114,8 +114,9 @@ void fish_update(const struct app *app, struct fish *fish, float delta_time)
|
||||||
}
|
}
|
||||||
if (fish->wander_step >= 1.0) {
|
if (fish->wander_step >= 1.0) {
|
||||||
fish->state = FISH_STATE_WANDER_DONE;
|
fish->state = FISH_STATE_WANDER_DONE;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
fish->wander_step += 0.05 * delta_time;
|
fish->wander_step += 0.1 * delta_time;
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case FISH_STATE_WANDER_DONE: {
|
case FISH_STATE_WANDER_DONE: {
|
||||||
|
@ -207,6 +208,7 @@ void app_loop(struct app *app) {
|
||||||
if (event.type == SDL_QUIT) {
|
if (event.type == SDL_QUIT) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
prev_ticks = current_ticks;
|
||||||
|
|
||||||
{
|
{
|
||||||
SDL_Delay(1);
|
SDL_Delay(1);
|
||||||
|
|
Loading…
Reference in a new issue