This example program shows you how to make a day/night cycle with specific colors. For instance, you could make evenings red, nights blue, and daytime yellow. Or, you could change it up entirely and make it however you want! It can be used directly in your program, however you should try to understand how the system works before attempting it. If you don't understand the system, it can be hard to try to add it to your own program.

This program draws a boring grass field with a character sprite placed in the center. It then loads up the color cycle system and applies the colors for the current time of day. The colors are based on the hour, and will change as the hour changes. If you press A, it switches to a different loop which allows you to change the hour at will. The hour will show up in the upper left corner if you're in this mode; press left and right to change the hour.

The day/night cycle system works like this:

  • First, it reads the original Red, Blue, and Green color values for EVERY SINGLE color in the SP and BG color palettes, and stores them in an array.
  • Next, it loads up the color offsets defined in the DATA section at the bottom of the code.
  • There's a function which checks the time (which should run in the main "Game" loop), and if the time has crossed over the hour, the system calls the function which updates all the colors.
  • The function that updates all the colors basically sets each color in the SP and BG palettes by taking the original colors and altering them based on the offsets given.

Technical stuff (ignore if you don't care): The colors are altered geometrically instead of linearly. This makes it so that dark colors don't all turn black and melt into each other, and bright colors don't all turn white. However, a linear color change doesn't necessarily look bad; it just has a different "mood". Try to keep color offsets in the negatives; if you stray too far into the positives, the colors start to look really weird.

Feel free to use this in anything you want. You don't have to credit me, but it would be nice. The only thing I don't want is for you to claim it as your own... but I can't really stop you. Just know that it'll make me sad :,(Timecol2

Ad blocker interference detected!

Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.