Powered by Create your own unique website with customizable templates.
CREVIS
  • Home
  • Devblog
  • Apply
  • About
  • Download
ALEC'S

Developer Blog

Day/Night System Complete!

10/13/2017

0 Comments

 
Hello everyone! I have completed the day/night system in a test room! It now must be put into the game, but that's as easy as dropping the object in the game room. It needs a bit of tweaking and I'm going to replace the sun and moon with proper sprites eventually. Here's what it looks like.
Picture
So, how does it work? There are a ton of different elements in within the day/night system that you probably would not have thought of.

Time
The day/night system correlates with the time. Time is a value between 0-1440. There's one minute to an hour, making each day 24 hours. 1440 is the amount of seconds in a day. I will be referring to the numeric value of time (0-1440) as "raw time."

A proportion calculates the angle of the sun based on the raw time. The sun is then drawn on the ellipse at that angle.
Picture
In this example, the proportion calculates that the sun should be at 90 degrees on the ellipse at 12:59 PM (780 raw time). It gets the position of the sun from a series of scripts.
Picture
The functions are used to get "xx" and "yy" (the green circle) given the length (len) and the angle (dir)
In GameMaker, the functions lengthdir_x and lengthdir_y exist. These functions are used to find a specific point at a specific length and angle. This may sound complicated, but think about it as finding a point on a circle's circumference given the radius and the angle. With the day/night system, there's one problem... it's not a circle - it's an ellipse. An ellipse's radius is always changing. So, I needed an equation to get the ellipse's radius at any given time. I found a formula that did just this.
Picture
This equation allowed me to find the ellipse's radius given the angle and the major and minor radii. With the radius of the ellipse stored in a variable, all I had to do was plug it into the lengthdir_x and lengthdir_y scripts to get the positions of the sun/moon.
The fading backgrounds was done very simply with a phase system. Phases are certain spans of time with specific backgrounds. There is a phase for every fading animation as well as static backgrounds. To get the fading effect, two images are stacked: the image to fade from and the image to fade to. The image to fade to starts with zero opacity and then increases to maximum opacity as time goes on. This system uses NO alarms and is very dynamic.

Until next time!
0 Comments



Leave a Reply.

    Task

    February's task is to improve the combat system and create a system for enemies and their AI.

    Author

    The author of the blog is Alec. He posts weekly, usually on the weekends on Saturday.

    Categories

    All
    Crevis
    Life
    Nesus
    Website

    Archives

    July 2019
    March 2019
    February 2019
    October 2018
    December 2017
    October 2017
    August 2017
    July 2017
    May 2017
    April 2017
    March 2017
    February 2017
    January 2017
    December 2016
    November 2016
    October 2016
    September 2016
    August 2016
    July 2016

Powered by Create your own unique website with customizable templates.
  • Home
  • Devblog
  • Apply
  • About
  • Download