Day/Night Cycle

Started by Seltzer Cole, May 29, 2012, 04:37:08 am

Previous topic - Next topic

Seltzer Cole

May 29, 2012, 04:37:08 am Last Edit: May 29, 2012, 04:47:43 am by Seltzer Cole
First and foremost this is a parallel process. It does not keep track of days, it just gives the game a dawn, day, dusk, and night.

This system will give you a 14 minute day/night within your game. Changing the time to more or less than 14 minutes is easy to do and I will explain that as well. Dawn is 3 minutes, Day is 5, Dusk 3, Night 5. Which = 14 Minutes.

The Common Event needed,
Spoiler: ShowHide

: Branch End

Understanding the Common Event,
Spoiler: ShowHide
The "Wait 20" equals 1 second.
There are only 2 variables used that can be named to whatever you want. One is used for keeping track of seconds and the other keeps track of minutes. The wait will continually increase the "Variable Day/Night Seconds" by 1 until it hits 60, then it will increase the "Variable Day/Night Minutes" by 1 and reset the seconds so it can start the process over. When "Variable Day/Night Minutes" reaches 14 which is approximately 14 minutes, it resets the minutes so everything can start over and it would then be morning.
A picture is displayed for dawn, day, dusk, and night as the "Change Screen Color Tone" is used to dim the screen out or brighten it so it appears that the sun is rising and falling towards night time.
You will need to set a "Condition Switch" to turn this common event on, so just stick it at the beginning of your game or whenever you would like to turn it on/off to control whether the cycle of the sun plays a factor.
You need pictures to display. I will add in free ones below.
To change the times at which the 4 times of day appear, just edit the Conditional Branch Variable of the Minute (Of dawn, day, dusk and night) and change it to whatever you wish.

Uses for this Common Event,
Spoiler: ShowHide
- Particular times of the day based quests
- Particular times of the day based skills such as farming
- Particular times of the day based enemies such as enemies that only appear at night
- etc.... you get the idea

There are multiple ways you could improve on this. I am lazy right now so I won't add anything to it. But idea's are adding in not only day/night cycle but keeping track of days/months/years.

The pictures needed,

Spoiler: ShowHide

Just copy and save them on your PC. Then go into your Material Base and upload them as Pictures.

If you feel that I failed to mention anything than ask. I didn't really give a detailed description on understanding or how to add this into your game, so if you are new to the program, ask me and i'll answer. The reason you need a switch for this by the way is in case you enter a building and hate that the lights are still out at night time. This isn't apart of the idea in my game though so I didn't add that. But yeah... Thanks and bye.
You know you play video games to much when you put sunglasses on and whisper "Plus 10 Appearance"

If at first you don't succeed, call it version 1.0


I have a script that handles this, but this is interesting none the less. I'm starting to learn to use conditional branches and variables to perform more complicated functions, so this was useful to look at.


Quote from: Seltzer Cole on May 29, 2012, 04:37:08 am
The "Wait 20" equals 1 second.

This is only when the game is not run in Smooth Mode, which everybody does, so 40 frames equals 1 second unless you are one of them few. If you want to change it, press F1 while playing the game and change the option.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.


No, that works in events regardless. Frame rate within the game is different than frame rate that is being displayed. Smooth Mode just makes the game skip a frame during rendering, but it still takes that frame into account during calculation. So basically in events it's always 20 (because in events it's actually every other frame, it's made like that in the scripts) and in the scripts it's 40 regardless of Smooth Mode.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS

Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.