|
|
Re: Time display
[Re: Widi]
#324883
05/23/10 20:10
05/23/10 20:10
|
Joined: Nov 2009
Posts: 89 Germany, NRW
TrackingKeks
Junior Member
|
Junior Member
Joined: Nov 2009
Posts: 89
Germany, NRW
|
I would do it in a complete different way: Declare 4 Variables for seconds, minutes, hours and days, in the while loop you could add every time to seconds 1. When seconds reaches 60, seconds=0, minutes+=1...
Perhaps it is easier to do it this way..
Gamestudio: A7.82 Commercial/A8 Commercial System specs (Laptop): Windows 7 64bit DirectX v10.1 Intel Core i7-720QM CPU @ 1,60 GHz 4GB DDR2 Ram NVIDIA GeForce GT 230M (1024MB)
|
|
|
Re: Time display
[Re: Truth]
#324885
05/23/10 20:15
05/23/10 20:15
|
Joined: Aug 2007
Posts: 1,922 Schweiz
Widi
Serious User
|
Serious User
Joined: Aug 2007
Posts: 1,922
Schweiz
|
ups, sorry my fault. Use two seperate vars for minutes and days and one for all together:
var time_minute = 0;
var time_hour = 0;
var time_day;
time_minute += time_step/8;
if (time_minute > 60)
{
time_minute -= 60;
time_hour ++;
}
time_day = (time_hour * 100) + time_minute;
Last edited by Widi; 05/23/10 20:15.
|
|
|
Re: Time display
[Re: Widi]
#324900
05/23/10 20:56
05/23/10 20:56
|
Joined: Apr 2010
Posts: 172
wdlmaster
Member
|
Member
Joined: Apr 2010
Posts: 172
|
the daytime should represent the seconds of the day. In this case, the variable ranges from 0 ... 86399. From this number, you can calculate every other time element. The cycle() function is useful for this:
var day, hr, mn, sc;
sc = integer(cycle (day,0,60));
mn = integer(cycle (day / 60,0,60));
hr = integer(day / 3600);
The advantage: you can change the time back and forth and everything stays synchronized. You can even calculate other time-dependent things like sky color, sun position etc. Just from this single variable...
|
|
|
Re: Time display
[Re: Widi]
#324957
05/24/10 05:04
05/24/10 05:04
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
Expert
|
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
Give this a try. Its more in keeping with your original concept.
...
// increase time
time_day += time_step/8; // increase "time of day" variable
if( cycle(time_day, 0, 100) > 59) { time_day += 40; } // skip to end of hour
if( time_day >= 2400 ) { time_day -= 2400; } // don't let it go too far
if( time_day < 0 ) { time_day += 2400; } // or too low
But I too feel WDLmasters concept is better...
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
|