summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/area.c54
1 files changed, 16 insertions, 38 deletions
diff --git a/src/area.c b/src/area.c
index f8857b2..b660cae 100644
--- a/src/area.c
+++ b/src/area.c
@@ -29,6 +29,7 @@ blit_map_layers(struct area *area)
SDL_Color colors[256];
int i;
SDL_Rect dstrect;
+ enum area_layer l;
for (i = 0; i < 256; ++i) {
colors[i].r = (i % 8) * 36;
@@ -41,47 +42,24 @@ blit_map_layers(struct area *area)
dstrect.w = area->map->width * area->map->tilewidth;
dstrect.h = area->map->height * area->map->tileheight;
- area->map_layers[AREA_LAYER_BOT] = SDL_CreateRGBSurface(
- SDL_HWSURFACE | SDL_SRCCOLORKEY,
- area->map->width * area->map->tilewidth,
- area->map->height * area->map->tileheight,
- 8, 0, 0, 0, 0);
- SDL_FillRect(area->map_layers[AREA_LAYER_BOT], &dstrect,
- SDL_MapRGB(area->map_layers[AREA_LAYER_BOT]->format,
- 0xFC, 0x00, 0xFF));
- SDL_SetColorKey(area->map_layers[AREA_LAYER_BOT], SDL_SRCCOLORKEY,
- SDL_MapRGB(area->map_layers[AREA_LAYER_BOT]->format,
- 0xFC, 0x00, 0xFF));
- SDL_SetColors(area->map_layers[AREA_LAYER_BOT], colors, 0, 256);
+ for (l = 0; l < AREA_LAYERS_MAX; ++l) {
+ area->map_layers[l] = SDL_CreateRGBSurface(
+ SDL_HWSURFACE | SDL_SRCCOLORKEY,
+ area->map->width * area->map->tilewidth,
+ area->map->height * area->map->tileheight,
+ 8, 0x00, 0x00, 0x00, 0x00);
+ SDL_FillRect(area->map_layers[l], &dstrect,
+ SDL_MapRGB(area->map_layers[l]->format,
+ 0xFC, 0x00, 0xFF));
+ SDL_SetColorKey(area->map_layers[l], SDL_SRCCOLORKEY,
+ SDL_MapRGB(area->map_layers[l]->format,
+ 0xFC, 0x00, 0xFF));
+ SDL_SetColors(area->map_layers[l], colors, 0, 256);
+ }
+
blit_map_layer(area, MAP_LAYER_GROUND, AREA_LAYER_BOT);
blit_map_layer(area, MAP_LAYER_OBJ_LOW, AREA_LAYER_BOT);
-
- area->map_layers[AREA_LAYER_MID] = SDL_CreateRGBSurface(
- SDL_HWSURFACE | SDL_SRCCOLORKEY,
- area->map->width * area->map->tilewidth,
- area->map->height * area->map->tileheight,
- 8, 0, 0, 0, 0);
- SDL_FillRect(area->map_layers[AREA_LAYER_MID], &dstrect,
- SDL_MapRGB(area->map_layers[AREA_LAYER_MID]->format,
- 0xFC, 0x00, 0xFF));
- SDL_SetColorKey(area->map_layers[AREA_LAYER_MID], SDL_SRCCOLORKEY,
- SDL_MapRGB(area->map_layers[AREA_LAYER_MID]->format,
- 0xFC, 0x00, 0xFF));
- SDL_SetColors(area->map_layers[AREA_LAYER_MID], colors, 0, 256);
blit_map_layer(area, MAP_LAYER_OBJ_MID, AREA_LAYER_MID);
-
- area->map_layers[AREA_LAYER_TOP] = SDL_CreateRGBSurface(
- SDL_HWSURFACE | SDL_SRCCOLORKEY,
- area->map->width * area->map->tilewidth,
- area->map->height * area->map->tileheight,
- 8, 0, 0, 0, 0);
- SDL_FillRect(area->map_layers[AREA_LAYER_TOP], &dstrect,
- SDL_MapRGB(area->map_layers[AREA_LAYER_TOP]->format,
- 0xFC, 0x00, 0xFF));
- SDL_SetColorKey(area->map_layers[AREA_LAYER_TOP], SDL_SRCCOLORKEY,
- SDL_MapRGB(area->map_layers[AREA_LAYER_TOP]->format,
- 0xFC, 0x00, 0xFF));
- SDL_SetColors(area->map_layers[AREA_LAYER_TOP], colors, 0, 256);
blit_map_layer(area, MAP_LAYER_OBJ_HIGH, AREA_LAYER_TOP);
}