diff options
author | P. J. McDermott <pjm@nac.net> | 2013-03-05 14:33:18 (EST) |
---|---|---|
committer | P. J. McDermott <pjm@nac.net> | 2013-03-05 14:33:18 (EST) |
commit | 5c4882bfc0182195500c24277d79a9993f58ee28 (patch) | |
tree | 468ac8f98ac8ea52a3a13752ab7a1ddc62fb6161 | |
parent | 7aee23711d3bc2c1fa3f8fd56e14075e895f3263 (diff) | |
download | overworld-rpg-5c4882bfc0182195500c24277d79a9993f58ee28.zip overworld-rpg-5c4882bfc0182195500c24277d79a9993f58ee28.tar.gz overworld-rpg-5c4882bfc0182195500c24277d79a9993f58ee28.tar.bz2 |
src/main.c: It's summer somewhere...
-rw-r--r-- | src/main.c | 24 |
1 files changed, 19 insertions, 5 deletions
@@ -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: \ + * * <https://en.wikipedia.org/wiki/Sunrise_equation> \ + * * <http://www.esrl.noaa.gov/gmd/grad/solcalc/sunrise.html>\ + */ \ + 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; |