It is currently Fri Jul 10, 2020 5:46 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Getting sun light from game time
PostPosted: Sun Dec 13, 2015 8:12 am 
Offline
Addict
Addict
User avatar

Joined: Mon Oct 26, 2015 2:55 am
Posts: 925
Location: UA
This proc allows very smooth changing of daylight.
It is hard for me to explain how it works, so just try 8)
The settings here are strange and just for test, should redefine.

If you have some improvements that would be nice.

Code:
Procedure.f GetSunLight (TimeHour, TimeMinute)
   #HOUR_MINUTES = 60
   Define HMod.d
   Macro Approx (HourMin, HourMax, TimeHour, TimeMinute)
      ((HourMax * #HOUR_MINUTES + #HOUR_MINUTES-1) - (TimeHour * #HOUR_MINUTES + TimeMinute)) / ((HourMax * #HOUR_MINUTES + #HOUR_MINUTES-1) - HourMin * #HOUR_MINUTES)
   EndMacro
        Select TimeHour
         Case 0, 1, 2, 3, 4, 5 ; 0.1 at 5:59
            HMod = 0.1 - 0.1 * Approx (0, 5, TimeHour, TimeMinute)
         Case 6, 7, 8       ; 0.2 at 8:59
            HMod = 0.2 - 0.1 * Approx (6, 8, TimeHour, TimeMinute)
         Case 9             ; 0.3 at 9:59
            HMod = 0.3 - 0.1 * Approx (9, 9, TimeHour, TimeMinute)
         Case 10            ; 0.4 at 10:59
            HMod = 0.4 - 0.1 * Approx (10, 10, TimeHour, TimeMinute)
         Case 11            ; 0.6 at 11:59
            HMod = 0.6 - 0.2 * Approx (11, 11, TimeHour, TimeMinute)
         Case 12, 13, 14    ; 1.0 at 14:59
            HMod = 1.0 - 0.4 * Approx (12, 14, TimeHour, TimeMinute)
         
         Case 18, 19, 20      ; 0.6 at 20:59
            HMod = 0.6 + 0.4 * Approx (18, 20, TimeHour, TimeMinute)
         Case 21, 22         ; 0.2 at 22:59
            HMod = 0.2 + 0.4 * Approx (21, 22, TimeHour, TimeMinute)
         Case 23            ; 0.0 at 23:59
            HMod = 0.0 + 0.2 * Approx (23, 23, TimeHour, TimeMinute)
         Default
            HMod = 1.0
        EndSelect
      UndefineMacro Approx
   ProcedureReturn HMod
EndProcedure

_________________
Kind of copyleft notify: all the source code created by me and posted on Purebasic official forums is free to use and modification in all possible (and several impossible) ways for anyone, without asking my permission


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye