summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorP. J. McDermott <pjm@nac.net>2013-03-02 14:46:45 (EST)
committer P. J. McDermott <pjm@nac.net>2013-03-02 14:58:04 (EST)
commit48b9ee5ced72522a086146728f0772720bdfde7d (patch)
treead10d8063db0e3e3394945783c9470e21a67c096
parent5c8d2956859492b5324c1ffd2b18db74a2d34913 (diff)
downloadoverworld-rpg-48b9ee5ced72522a086146728f0772720bdfde7d.zip
overworld-rpg-48b9ee5ced72522a086146728f0772720bdfde7d.tar.gz
overworld-rpg-48b9ee5ced72522a086146728f0772720bdfde7d.tar.bz2
src/main.c: Run a day->night palette cycling demo.
-rw-r--r--src/main.c40
1 files changed, 30 insertions, 10 deletions
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 ;