#include #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); }