diff options
Diffstat (limited to 'src/area.c')
-rw-r--r-- | src/area.c | 45 |
1 files changed, 40 insertions, 5 deletions
@@ -26,11 +26,33 @@ area_new(struct map *map) static void blit_map_layers(struct area *area) { + SDL_Color colors[256]; + int i; + SDL_Rect dstrect; + + for (i = 0; i < 256; ++i) { + colors[i].r = (i % 8) * 36; + colors[i].g = (i % 64 / 8) * 36; + colors[i].b = (i / 64) * 85; + } + + dstrect.x = 0; + dstrect.y = 0; + 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, - 32, 0, 0, 0, 0); + 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); blit_map_layer(area, MAP_LAYER_GROUND, AREA_LAYER_BOT); blit_map_layer(area, MAP_LAYER_OBJ_LOW, AREA_LAYER_BOT); @@ -38,14 +60,28 @@ blit_map_layers(struct area *area) SDL_HWSURFACE | SDL_SRCCOLORKEY, area->map->width * area->map->tilewidth, area->map->height * area->map->tileheight, - 32, 0, 0, 0, 0); + 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, - 32, 0, 0, 0, 0); + 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); } @@ -60,7 +96,6 @@ blit_map_layer(struct area *area, enum map_layer map_layer, Uint32 mts_lastgid; SDL_Rect tilerect, layerrect; - SDL_SetColorKey(area->map_layers[area_layer], SDL_SRCCOLORKEY, 0); for (i = 0; i < area->map->width * area->map->height; ++i) { gid = area->map->layers[map_layer].tiles[i]; if (gid == 0) { @@ -138,7 +173,7 @@ render_area_to_surface(struct area *area, SDL_Rect *arearect, /* Fast fill with black to avoid artifacts in off-map pixels. */ /* NB: This is gray, at least temporarily. */ SDL_FillRect(surface, &dstrect, - SDL_MapRGB(surface->format, 63, 63, 63)); + SDL_MapRGB(surface->format, 0, 0, 0)); /* For demo */ tmprect.x = dstrect.x + 120 - 8; |