From 5c4882bfc0182195500c24277d79a9993f58ee28 Mon Sep 17 00:00:00 2001 From: P. J. McDermott Date: Tue, 05 Mar 2013 14:33:18 -0500 Subject: src/main.c: It's summer somewhere... --- diff --git a/src/main.c b/src/main.c index a8700cd..0873005 100644 --- a/src/main.c +++ b/src/main.c @@ -11,28 +11,42 @@ do { \ vp->x = x + map->tilewidth / 2 - vp->w / 2; \ vp->y = y + map->tileheight / 2 - vp->h / 2; \ - if (i % i_max < i_max / 4) { \ + /* \ + * See the following resources when computing realistic \ + * daylight cycles: \ + * * \ + * * \ + */ \ + if (i % i_max < i_max / 6 * 2) { \ + /* 00:00 - 04:00 */ \ + t_max = i_max / 6 * 2; \ pal_start = map->palettes[MAP_PALETTE_MORN] \ .palette->palette; \ pal_end = map->palettes[MAP_PALETTE_DAY] \ .palette->palette; \ - } else if (i % i_max < i_max / 4 * 2) { \ + } else if (i % i_max < i_max / 6 * 4) { \ + /* 04:00 - 12:00 */ \ + t_max = i_max / 6 * 2; \ pal_start = map->palettes[MAP_PALETTE_DAY] \ .palette->palette; \ pal_end = map->palettes[MAP_PALETTE_EVE] \ .palette->palette; \ - } else if (i % i_max < i_max / 4 * 3) { \ + } else if (i % i_max < i_max / 6 * 5) { \ + /* 12:00 - 20:00 */ \ + t_max = i_max / 6 * 1; \ pal_start = map->palettes[MAP_PALETTE_EVE] \ .palette->palette; \ pal_end = map->palettes[MAP_PALETTE_NIGHT] \ .palette->palette; \ } else { \ + /* 04:00 - 12:00 */ \ + t_max = i_max / 6 * 1; \ pal_start = map->palettes[MAP_PALETTE_NIGHT] \ .palette->palette; \ pal_end = map->palettes[MAP_PALETTE_MORN] \ .palette->palette; \ } \ - if (!cycle_palettes_cosine(i, i_max / 4, \ + if (!cycle_palettes_cosine(i, t_max, \ pal_start, pal_end, pal)) { \ warn("Failed to cycle palettes"); \ } \ @@ -86,7 +100,7 @@ main(void) /* Demo */ { Uint32 start, end; - int i, i_max; + int i, i_max, t_max; int x, y; SDL_Palette *pal_start, *pal_end; -- cgit v0.9.1