diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/level.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/src/level.c b/src/level.c index 7349e23..cc81b2f 100644 --- a/src/level.c +++ b/src/level.c @@ -19,6 +19,7 @@ #include <SDL.h> #include <stdlib.h> +#include "defs.h" #include "level.h" #include "map.h" #include "output.h" @@ -66,6 +67,7 @@ int db_level_play(SDL_Renderer *renderer, struct db_level *level) { struct db_map *map; + SDL_Texture *map_texture; db_dbg("Playing %s/%s", level->game_id, level->level_id); @@ -73,8 +75,24 @@ db_level_play(SDL_Renderer *renderer, struct db_level *level) if (map == NULL) { return -1; } + map_texture = db_map_render(map, renderer); - SDL_RenderClear(renderer); + if (SDL_SetRenderDrawColor(renderer, + DB_COLOR_BACK_R, DB_COLOR_BACK_G, + DB_COLOR_BACK_B, DB_COLOR_BACK_A) != 0) { + db_err("Failed to set drawing color (%s)", SDL_GetError()); + return -1; + } + if (SDL_RenderClear(renderer) != 0) { + db_err("Failed to clear screen (%s)", SDL_GetError()); + return -1; + } + if (SDL_RenderCopy(renderer, map_texture, NULL, NULL) != 0) { + db_err("Failed to copy texture (%s)", SDL_GetError()); + return -1; + } + SDL_RenderPresent(renderer); + SDL_Delay(1000); return 0; } |