From 48b9ee5ced72522a086146728f0772720bdfde7d Mon Sep 17 00:00:00 2001 From: P. J. McDermott Date: Sat, 02 Mar 2013 14:46:45 -0500 Subject: src/main.c: Run a day->night palette cycling demo. --- diff --git a/src/main.c b/src/main.c index 3f20335..d2f10f9 100644 --- a/src/main.c +++ b/src/main.c @@ -38,8 +38,6 @@ main(void) if (map == NULL) { err(1, "Where's the map, George?"); } - a = area_new(map); - for (i = 0; i < 256; ++i) { colors[i].r = (i % 8) * 36; colors[i].g = (i % 64 / 8) * 36; @@ -48,14 +46,7 @@ main(void) if (!SDL_SetPalette(vp->screen, SDL_LOGPAL, colors, 0, 256)) { warn("Failed to set palette"); } - for (i = 0; i < 256; ++i) { - colors[i].r = i; - colors[i].g = i; - colors[i].b = i; - } -/* if (!SDL_SetPalette(vp->screen, SDL_PHYSPAL, colors, 0, 256)) { - warn("Failed to set palette"); - }*/ + a = area_new(map, vp); for (e = map->map_exits_head; e != NULL; e = e->next) { debug("Map exit (size %dx%d) at (%d,%d) " @@ -67,7 +58,36 @@ main(void) e->target_x_coord, e->target_y_coord); } + render_area_to_viewport(a, vp); + { + float step; + for (step = 1.0; step >= 0.25; step -= 0.00390625) { + 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; + colors[i].r *= step; + colors[i].g *= step; + colors[i].b *= step; + } + if (!SDL_SetPalette(vp->screen, SDL_LOGPAL, colors, 0, 256)) { + warn("Failed to set palette"); + } + SDL_Flip(vp->screen); + SDL_Delay(10); + } + } + SDL_Delay(1000); + /* Demo */ + 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; + } + if (!SDL_SetPalette(vp->screen, SDL_LOGPAL, colors, 0, 256)) { + warn("Failed to set palette"); + } i = 0; start = SDL_GetTicks(); x = 19 * map->tilewidth ; -- cgit v0.9.1