diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/sdl/draw.c | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/src/sdl/draw.c b/src/sdl/draw.c index 09da95e..2dab2ee 100644 --- a/src/sdl/draw.c +++ b/src/sdl/draw.c @@ -5,6 +5,8 @@ #include "draw.h" #include "sprites.h" +#define M_2_PI (2.0 * 3.1415926) + static size_t get_cell_size( const draw_ctx_t * const draw_ctx @@ -62,6 +64,27 @@ draw_cell( } static void +draw_home( + draw_ctx_t * const draw_ctx, + const sok_pos_t pos +) { + const SDL_Rect rect = get_cell_rect(draw_ctx, pos); + + SDL_Texture *tex = draw_ctx->sprites[SPRITE_HOME]; + if (sok_ctx_is_done(draw_ctx->ctx)) { + const Uint32 ticks = SDL_GetTicks(); + const double angle = 10 * sin(ticks * M_2_PI / 1000.0); + if (SDL_RenderCopyEx(draw_ctx->renderer, tex, NULL, &rect, angle, NULL, SDL_FLIP_NONE)) { + die("SDL_RenderCopyEx(): %s", SDL_GetError()); + } + } else { + if (SDL_RenderCopy(draw_ctx->renderer, tex, NULL, &rect)) { + die("SDL_RenderCopy(): %s", SDL_GetError()); + } + } +} + +static void draw_border( draw_ctx_t * const draw_ctx, const sok_pos_t level_size @@ -141,7 +164,7 @@ draw_sprites_on_home( void * const data ) { draw_ctx_t * const draw_ctx = data; - draw_cell(draw_ctx, pos, SPRITE_HOME); + draw_home(draw_ctx, pos); return true; } @@ -320,9 +343,9 @@ set_bg_won_color( // gen color const SDL_Color c = { - .r = 0x66 + 0x33 * sinf((1000 + ticks) * 2.0 * 3.14159 / 2000.0), - .g = 0x66 + 0x33 * sinf((3000 + ticks) * 2.0 * 3.14159 / 5000.0), - .b = 0x66 + 0x33 * sinf((5000 + ticks) * 2.0 * 3.14159 / 7000.0), + .r = 0x66 + 0x33 * sinf((1000 + ticks) * M_2_PI / 2000.0), + .g = 0x66 + 0x33 * sinf((3000 + ticks) * M_2_PI / 5000.0), + .b = 0x66 + 0x33 * sinf((5000 + ticks) * M_2_PI / 7000.0), .a = 0xFF, }; |