Day Night Cycle, Am I doing it right?

9142

Villager
Member
Joined
Feb 26, 2016
Messages
13
Reaction score
4
First Language
English
Primarily Uses
I wanted to create a 4 tint day/night cycle with dawn, day, dusk and night. But I wonder if I'm doing it right with the common event. Please vet it for me and if I'm doing it wrong, please tell me what to do. Many thanks in advance.


I currently have a in game clock/time system and this common event is based on that system.


p.s idk if this post is posted in the correct section.


image.png
 
Last edited by a moderator:

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
Game Mechanics is for discussing the design of mechanics, not their implementation.  "How do I...?" questions belong in the support forum for the engine you are using.


I've moved this thread to RPGMaker MV. Please be sure to post your threads in the correct forum next time. Thank you.
 

YoraeRasante

Veteran
Veteran
Joined
Jun 6, 2014
Messages
1,643
Reaction score
420
First Language
Portuguese
Primarily Uses
RMMV
I think this would sometimes cause your game to turn colors out of order. For example, 20 would activate... all of them.


Besides the lack of a wait at the end, and a switch for when you do NOT want the colors to change like on the inside of houses.


I'd put the is in decreasing order, and one inside the else branch of the other... and ALL inside a conditional form to check if a switch "time tint" is on.


Also a wait of at least 5 frames at the end.
 

9142

Villager
Member
Joined
Feb 26, 2016
Messages
13
Reaction score
4
First Language
English
Primarily Uses
I think this would sometimes cause your game to turn colors out of order. For example, 20 would activate... all of them.


Besides the lack of a wait at the end, and a switch for when you do NOT want the colors to change like on the inside of houses.


I'd put the is in decreasing order, and one inside the else branch of the other... and ALL inside a conditional form to check if a switch "time tint" is on.


Also a wait of at least 5 frames at the end.
I see! Didn't realize the activating all of the tints part, that would be bad haha. If it's not too troublesome for you, could you give me a screenshot of the proper event so that I could learn and use for reference? Much appreciated. I'm still quite confused on the conditional branches part, so should I have 2 conditional branches or? 
 

YoraeRasante

Veteran
Veteran
Joined
Jun 6, 2014
Messages
1,643
Reaction score
420
First Language
Portuguese
Primarily Uses
RMMV
I'm sorry, my computer had a problem and is fixing right now.


But remember that checkbox on the bottom of the conditional branch? That box let's you have an "else" branch. Things inside it happen when the ones on the original fork so not.
 
Last edited by a moderator:

Dad3353

Veteran
Veteran
Joined
Mar 9, 2016
Messages
421
Reaction score
110
First Language
English
Primarily Uses
@9142...


Concerning the conditional stuff, it's easy (on the small scale we see here...) if one goes through asking the question in the place of the machine. Taking your code, and supposing an 'Hour' value of 16 (just for illustration...), we see...


Is Hour Greater or Equal To 19..?


Answer: No, so no Tint.1


Is Hour Greater or Equal To 5..?


Answer: Yes, so Tint 2..!


Is Hour Greater or Equal To 8..?


Answer: Yes, so Tint 3..!


Is Hour Greater or Equal To 16..?


Answer: Yes, so Tint 4


As we can see, the Tints 2 and 3 have been applied, to be finally over-ridden by Tint 4. How to prevent this..?


Firstly, by having the tests in the order of magnitude, then by having each test dependant upon the preceding test, like this...

Is Hour Greater or Equal To 19..?


      Yes, Tint 1


Else


    Is Hour Greater or Equal To 16..?


        Yes, Tint 2


    Else


        Is Hour Greater or Equal To 8..?


            Yes, Tint 3


        Else


            Is Hour Greater or Equal To 5..?


                Tint 4


            End


        End


    End


End



In this structure, with Hour value of 16 again, once we reach the second test, the following tests are not executed. Once a test is satisfied, the others are no longer relevant.


One remark... what happens when Hour has a value of 2..? This case would cause all of the tests to fail. I would suggest a 'fail-safe' 'else'  to come after the 'Greater or Equal To 5' such that any other value gives Tint 1 (ie: the 'Night' Tint...). This would look like...

...


        Else


            Is Hour Greater or Equal To 5..?


                Tint 4


             Else


                Tint 1


            End


        End


    End


End



Try this out on a dummy Project to see how it responds to your needs; read through again if all is not clear or come back with questions


Hope this helps.
 
Last edited by a moderator:

bomblord

Veteran
Veteran
Joined
Apr 13, 2016
Messages
87
Reaction score
11
First Language
English
Primarily Uses
I've been working on a day/night script in engine for a while now and while I won't pretend my solution is the best it's worked for me and runs great





A quick breakdown of what is happening. The minutes are increasing every 1/60th of a second (I just have it this low for testing purposes up it to whatever number of frames you want. 60 frames = 1 second).

Every 60 minutes it resets and increases hours by 1
Every 24 hours it increases day by 1

I have the game set to tint the screen at certain hours (the hours can be set to whatever you want this is just an approximation)

I also have switches for morning, day, night, and evening so I can tie events into them.

Every check also has an additional check to make sure it's within a range of hours as opposed to assuming that the script has run in order. This prevents issues with manually adjusting the time via an event

I also have everything tied to variables so I can attach events to happen based on hours minutes or days.
 
Last edited by a moderator:

9142

Villager
Member
Joined
Feb 26, 2016
Messages
13
Reaction score
4
First Language
English
Primarily Uses
@Dad3353 I've tried the method mentioned by you previously and after testing, the game would only tint the screen based on the first check, eg. the first one check in the event was set to dawn, as seen below. And even after the hour, which in this case is 8 has passed. The screen remained tinted at "Dawn". 


@bomblordYour script looks interesting! Shall give it a try! Thank you all for the input!


edit: I tried @bomblord's Script and it works! However when you enter buildings wouldn't the screen tint as well? I tried separating the time and the tint into 2 separate common events but my game just lags.


Screen Shot 2016-09-26 at 1.34.49 am.png
 
Last edited by a moderator:

YoraeRasante

Veteran
Veteran
Joined
Jun 6, 2014
Messages
1,643
Reaction score
420
First Language
Portuguese
Primarily Uses
RMMV
Don't forget to add a wait at the end, since it is a parallel process without the wait it would go again every single frame and that is HEAVY...
 

bomblord

Veteran
Veteran
Joined
Apr 13, 2016
Messages
87
Reaction score
11
First Language
English
Primarily Uses
@Dad3353 I've tried the method mentioned by you previously and after testing, the game would only tint the screen based on the first check, eg. the first one check in the event was set to dawn, as seen below. And even after the hour, which in this case is 8 has passed. The screen remained tinted at "Dawn". 


@bomblordYour script looks interesting! Shall give it a try! Thank you all for the input!


edit: I tried @bomblord's Script and it works! However when you enter buildings wouldn't the screen tint as well? I tried separating the time and the tint into 2 separate common events but my game just lags.


View attachment 48515



If you are running it as a parallel process remove the loop that may be causing your lag. You may also want to consider shortening your transition down from 360 frames unless you need it to be running for 6 entire seconds.

As for in buildings I have an event I just copy paste in every building that stops the clock and removes the screen tinting. You could also build it into your doors if you want.
 

SlowMN

Villager
Member
Joined
Aug 18, 2016
Messages
21
Reaction score
0
First Language
English
Primarily Uses
I've been working on a day/night script in engine for a while now and while I won't pretend my solution is the best it's worked for me and runs great





A quick breakdown of what is happening. The minutes are increasing every 1/60th of a second (I just have it this low for testing purposes up it to whatever number of frames you want. 60 frames = 1 second).

Every 60 minutes it resets and increases hours by 1
Every 24 hours it increases day by 1

I have the game set to tint the screen at certain hours (the hours can be set to whatever you want this is just an approximation)

I also have switches for morning, day, night, and evening so I can tie events into them.

Every check also has an additional check to make sure it's within a range of hours as opposed to assuming that the script has run in order. This prevents issues with manually adjusting the time via an event

I also have everything tied to variables so I can attach events to happen based on hours minutes or days.
 How do you increase the time in this so the time periods for each variable last longer?
 

YoraeRasante

Veteran
Veteran
Joined
Jun 6, 2014
Messages
1,643
Reaction score
420
First Language
Portuguese
Primarily Uses
RMMV
Probably a separate common event. This one takes care of the time of day's tint, while the other takes care of actually calculating it.
 

bomblord

Veteran
Veteran
Joined
Apr 13, 2016
Messages
87
Reaction score
11
First Language
English
Primarily Uses
 How do you increase the time in this so the time periods for each variable last longer?

Change the wait on the first line
Right now it is set to 1 frame so every 1/60th of a second is 1 minute I have it set that high for testing purposes.

60 frames is 1 second in real time and I have it increase by 1 minute at the end of every wait period.

Some quick math
Setting the wait to 60 frames. You would get every 1 (real world) second would be 1 minute of game time. Meaning 1 (real world) minute would give you 1 hour game time. Which would give you 24 (real world) minute days


30 frames would be 1 minute every half second so 12 minute days


15 frames would be 1 minute every 1/4 second so 6 minute days.
120 frames would be 48 minute days

I've actually updated the script since posting this and removed the Day/Night/Evening Switches as I've found that I can just as easily check the time for event switches.
 
 
Last edited by a moderator:

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,865
Messages
1,017,059
Members
137,575
Latest member
akekaphol101
Top