summaryrefslogtreecommitdiffstats
path: root/src/area.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/area.c')
-rw-r--r--src/area.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/area.c b/src/area.c
new file mode 100644
index 0000000..3a03198
--- /dev/null
+++ b/src/area.c
@@ -0,0 +1,50 @@
+#include <SDL.h>
+#include "area.h"
+#include "layer.h"
+#include "viewport.h"
+
+void
+render_area_to_viewport(struct area *area, struct viewport *vp)
+{
+ SDL_Rect srcrect;
+ SDL_Rect dstrect;
+
+ srcrect.x = vp->x;
+ srcrect.y = vp->y;
+ srcrect.w = vp->w;
+ srcrect.h = vp->h;
+ dstrect.x = 0;
+ dstrect.y = 0;
+ dstrect.w = vp->w;
+ dstrect.h = vp->h;
+
+ render_area_to_surface(area, &srcrect, vp->screen, &dstrect);
+}
+
+void
+render_area_to_surface(struct area *area, SDL_Rect *arearect,
+ SDL_Surface *dst, SDL_Rect *dstrect)
+{
+ /* Fast fill with black to avoid artifacts in off-map pixels. */
+ SDL_FillRect(dst, dstrect, 0);
+
+ /* Blit ground layer. */
+ SDL_BlitSurface(area->map_layers[LAYER_GROUND], arearect,
+ dst, dstrect);
+
+ /* Blit low objects layer. */
+ SDL_BlitSurface(area->map_layers[LAYER_OBJ_LOW], arearect,
+ dst, dstrect);
+
+ /* TODO: Blit low sprites. */
+
+ /* Blit middle objects layer. */
+ SDL_BlitSurface(area->map_layers[LAYER_OBJ_MID], arearect,
+ dst, dstrect);
+
+ /* TODO: Blit high sprites. */
+
+ /* Blit high objects layer. */
+ SDL_BlitSurface(area->map_layers[LAYER_OBJ_HIGH], arearect,
+ dst, dstrect);
+}