How do I create a day/night cycle?

0 favourites
  • 3 posts
From the Asset Store
Fully commented source code/event sheet & sprites to create a space shooter game
  • I've been working on a day/night cycle for this game, and I have everything working so far. The Sun/Moon orbits properly, and the background changes colors smoothly based on the time of day. The only issue is, whenever I switch from night to day, because of the equations I use, there is a bright white flash on the screen for some reason I can't find. Can someone help me make this smoother?

    CurrentTime = The current time of day, which is increased every 0.01 seconds via the CurrentTimeScale variable, which at default should be 0.01, but for the sake of testing is sped up to 5.

    CurrentTimeScale = (Read above)

    CurrentTimeAmount = A decimal based on the percentage of the day completed. One day is 720 (timescalespeedhere) so if the day is at 360 out of 720, then CurrentTimeAmount would read as 0.5...

    IsDay is a simple variable to check if it is day or night. Instead of currenttime being 24 "hours" it is split in 'half' at 720 'minutes.'

    LastSkyR/G/B are the colorvalues that the background sets its color to.

  • Try moving the "On every tick" event before "is IsDay" event.

    If this doesn't work, could you share you project file? It's difficult to try running this code in my head :)


    On a side note, you can't run anything every 0.01s. On most devices the framerate will be around 60, which equals to 0.016s per frame, and you can't trigger any events faster than that.

    If I understand correctly, the full cycle takes 24 minutes? Then updating the whole thing on every frame is probably an overkill. I would do it every 0.5-1 second or so, it should still look smooth.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Changing where the tick event was worked. That was weird... Thanks a ton

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)