Controlling Colors and the Night Sky

Something I have been struggling with for my game is this: What do I do for the background? For a long time this was a non-issue as I did not yet have a theme, but one day I decided it needed something more than just a flat color. I tried a few things, but none of them worked very well. Then I found the thing that works, an image in Unity can have a color applied to it and this layers over the existing colors. With colored images this can look horrible, but on a white to black gradient it looks fine. So I popped into PowerPoint, mad a square, and applied a gradient fill from black at the edges to white at the center. After a bit of playing with the ratios I found something I liked and put it into Unity.

Now my backgrounds are a bit more interesting than just a flat color. But I decided I wanted more than that, I decided I wanted the background to react to the current state of the game. As such I had the color progress through a progression of colors dependent on the ratio of moves taken to moves used to create the puzzle and going to black if you go past that number.

This was all well and good, but the sudden change left something to be desired. As part of creating the star fields I discovered a function to have one color fade into another. In the star fields I only used the fading for the alpha value that controls transparency. But for this I needed the actual color changing part of the function. This came with a minor hiccup as I discovered a quirk of the function. In Unity you can layer a color on top of an image, and this color fade function layers another color on top of that. Once I figured that out (took a little while to figure out why the colors didn’t look right) the solution was simple: in the set up for a given scene set the base color to white, then use the function to set the starting color with a transition time of zero. I now have the correct starting color and no extra colors muddying things up.

I had now settled on the technical side of things (mostly, I did do a couple other things I am very happy with. But enough technical stuff for now) and now I needed to choose my colors. I had been experimenting with colors for a while at this point, putting different color progressions in each scene. But to make a long story short I settled on two principles for the background colors. Firstly, I decided to stick to a blue primary coloration, as the sky is blue even at night (it only looks black because of all the “light pollution” from modern electric lights in cities) and as stated in the post about the stars I was now going for a night sky theme. Secondly, was that the colors would progress from light to dark and back to light, mimicking the progression from twilight to night back to the dawn. But with the twist that if you go over the target number of moves it quickly drops to a very dark blue, showing you got lost in the night.

Perhaps I will change some part of this again in the future. But for now I am happy with were I have gotten.