We Have Weather Now
So the big to-do this week was adding weather. I want the game to have inclement weather so that it's in the player's interest to shelter against it (or have appropriate clothes). I want the weather to seem sufficiently real, but I also don't want to write a heavy meteorological system.
The compromise was to get some reasonable climate data (thanks NOAA!) for the game world, and write a simple algorithm to interpolate between winter and summer averages. It trends sinusoidally, with randomized variations, and includes temperature, precipitation, and cloudiness. Here's a glance:
If you click on the image, you can see it in more detail. In the top left corner, I've printed a description of the weather conditions, as well as the date. In the top right corner, you can see a UI element which depicts the sky. Originally, the weather was just that sky icon. But as it turned out, that wasn't a lot of real estate to tell the player what was going on. Particularly for something like rain, which barely showed up over the clouds in that UI image. Rather than expand the image, I decided I might as well make it intuitive, such that the player doesn't need to avert their eyes from the play area to know that it's raining. This was the result:
Some nice, old-school sprite rain! I also have a few icons setup for clear skies, partly cloudy, and day vs. night. Though again, the day/night cycle was really subtle with just that icon at the top. Once more, I decided to go nuts on intuitive UI, and wrote a day/night hex system. Which meant it was also time for...
New Hex Art
Astute viewers will notice that the hexes have changed a bit since last time. That's because I decided to give them a more pixel-perfect style, and did away with the shared border graphics. Now all hexes have painted borders matching their terrain type. I think the style is a step in the right direction too, as they look a bit more retro, and a bit less "whipped up in Flash."
These new hexes were created in such a way that it allowed me to easily create nighttime versions of each. I whipped up a nighttime color-shifting filter in Photoshop, and went to town. Here's the result:
Note the sky UI has also changed to reflect the time of day. I think day/night hexes will be a lot of fun to play with later, as I can add day/night images to hexes such as campfires or lights. I can also change things like the player's visual range and allow for powers like night vision at some point. The one hurdle I've encountered here is that water and plains are indistinguishable at night. That'll warrant some problem-solving.
You may also have noticed a new framerate counter. Yes, it's finally time to start considering performance. These hexes were getting quite heavy to begin with, and with weather sprites flying around, it was getting pretty bad, pretty quickly. Part of the new hex design did away with separate border images overlayed on each hex. I originally thought that would make things easier to maintain, but it's not worth the extra draw calls with alpha images.
The big performance win turned out to be not drawing offscreen hexes. It sounds pretty obvious, but I was a bit surprised (perhaps naively so) that Flash wasn't doing this for me. I figured Flash was pretty good about culling anything offscreen, especially as it was such a mature platform. Not so. One fairly simple culling algorithm later, and framerate went from 8ish to 28ish. Fast map-panning and smooth raindrop animations!
There's more to come. I'm still planning on seasonal hexes (at least winter), as well as dusk/dawn. But it may be time to start tackling player status or load/save of maps. Though, there might also be some housekeeping in order after this big burst of output. I have some things to un-hardcode now that I'm more satisfied with the way things look/work.
Until Tuesday! (Monday's a stat holiday, so I've got the day off!)