summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorP. J. McDermott <pj@pehjota.net>2021-03-24 09:41:23 (EDT)
committer P. J. McDermott <pj@pehjota.net>2021-03-24 09:41:23 (EDT)
commit5e0f3439d82a4ff04bf0ce5da47901129acf521e (patch)
tree2fed1ab431767a8161ce9fa611d336d5ec2b509f /src
parent79a828b2e0464b6768e98a48eef6497ea3960995 (diff)
downloaddodge-balls-5e0f3439d82a4ff04bf0ce5da47901129acf521e.zip
dodge-balls-5e0f3439d82a4ff04bf0ce5da47901129acf521e.tar.gz
dodge-balls-5e0f3439d82a4ff04bf0ce5da47901129acf521e.tar.bz2
level: Render map
Diffstat (limited to 'src')
-rw-r--r--src/level.c20
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;
}