diff options
Diffstat (limited to 'src/sdl')
-rw-r--r-- | src/sdl/draw.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/sdl/draw.c b/src/sdl/draw.c index 322bd7a..762976f 100644 --- a/src/sdl/draw.c +++ b/src/sdl/draw.c @@ -137,6 +137,19 @@ draw_on_goal( return true; } +static double +get_home_angle( + const draw_ctx_t * const draw_ctx +) { + if (draw_ctx->state == GAME_STATE_SOLVE) { + return 5 * sin(draw_ctx->ticks * M_2_PI / 2000.0); + } else if (sok_ctx_is_done(draw_ctx->ctx)) { + return 10 * sin(draw_ctx->ticks * M_2_PI / 1000.0); + } else { + return 0; + } +} + static bool draw_on_home( const sok_ctx_t * const ctx, @@ -147,9 +160,8 @@ draw_on_home( UNUSED(ctx); UNUSED(has_goal); draw_ctx_t * const draw_ctx = data; - const double angle = sok_ctx_is_done(draw_ctx->ctx) ? (10 * sin(draw_ctx->ticks * M_2_PI / 1000.0)) : 0; - draw_cell(draw_ctx, pos, SPRITE_HOME, angle); + draw_cell(draw_ctx, pos, SPRITE_HOME, get_home_angle(draw_ctx)); return true; } |