diff options
author | Paul Duncan <pabs@pablotron.org> | 2019-01-16 07:29:17 -0500 |
---|---|---|
committer | Paul Duncan <pabs@pablotron.org> | 2019-01-16 07:29:17 -0500 |
commit | d2a9d1132e1cb807fbb3e4132b67945f968ef5b7 (patch) | |
tree | 5170f0d136fdf3ac7bee54c79569141d29281494 /src/sdl | |
parent | c17f5a5377f959a7e67526e0ae89b329bf99a101 (diff) | |
download | sok-d2a9d1132e1cb807fbb3e4132b67945f968ef5b7.tar.bz2 sok-d2a9d1132e1cb807fbb3e4132b67945f968ef5b7.zip |
animate hero while solving
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; } |