Gamestudio Links
Zorro Links
Newest Posts
Newbie Questions
by fairtrader. 12/05/23 14:22
Zorro Trader GPT
by TipmyPip. 12/04/23 11:34
Square root rule
by Smallz. 12/02/23 09:15
RTest not found error
by TipmyPip. 12/01/23 21:43
neural function for Python to [Train]
by TipmyPip. 12/01/23 14:47
Xor Memory Problem.
by TipmyPip. 11/28/23 14:23
Training with command line parameters
by TipmyPip. 11/26/23 08:42
Combine USD & BTC Pairs In Asset Loop
by TipmyPip. 11/26/23 08:30
AUM Magazine
Latest Screens
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Who's Online Now
3 registered members (TedMar, AndrewAMD, fairtrader), 578 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
fairtrader, hus, Vurtis, Harry5, KelvinC
19019 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Time display #324863
05/23/10 18:50
05/23/10 18:50
Joined: Jun 2008
Posts: 146
London
T
Truth Offline OP
Member
Truth  Offline OP
Member
T

Joined: Jun 2008
Posts: 146
London
I have a time code (below) which displays on screen but this code goes right up to 13:99 for example, what can i add to make it go from 13:59 to 14:00. Thanks


function sky_move
{
time_day = 1355; // dawn of a new day 0600


while(1)
{
// increase time
time_day += time_step/8; // increase "time of day" variable
if( time_day >= 2400 ) { time_day -= 2400; } // don't let it go too far
if( time_day < 0 ) { time_day += 2400; } // or too low

Re: Time display [Re: Truth] #324864
05/23/10 18:58
05/23/10 18:58
Joined: Aug 2007
Posts: 1,922
Schweiz
Widi Offline
Serious User
Widi  Offline
Serious User

Joined: Aug 2007
Posts: 1,922
Schweiz
Sorry, but this code no make sense for me. Why is "time_day = 1355" dawn 0600?
if( time_day < 0 ) { time_day += 2400; } Why that?
what is time_day? seconds, minutes or hours?
How do you display 13:99? I see only one var...

Re: Time display [Re: Widi] #324873
05/23/10 19:45
05/23/10 19:45
Joined: Jun 2008
Posts: 146
London
T
Truth Offline OP
Member
Truth  Offline OP
Member
T

Joined: Jun 2008
Posts: 146
London
Thanks for replying, ignore the comments i changed the variable from dawn 0600 to 1355. if( time_day < 0 ) { time_day += 2400; } means it's a 24hr clock so if the variable reaches 2400 then start a new day 0000 its basically a 24hr clock without the : in the middle. i was just using the 13:99 as an example so it's really displayed like 1399.

Re: Time display [Re: Truth] #324877
05/23/10 19:54
05/23/10 19:54
Joined: Aug 2007
Posts: 1,922
Schweiz
Widi Offline
Serious User
Widi  Offline
Serious User

Joined: Aug 2007
Posts: 1,922
Schweiz
ok. But what is the problem now? If 13:59 means time_day = 1359 then you can add 1 and you have 1400

Re: Time display [Re: Widi] #324881
05/23/10 20:01
05/23/10 20:01
Joined: Jun 2008
Posts: 146
London
T
Truth Offline OP
Member
Truth  Offline OP
Member
T

Joined: Jun 2008
Posts: 146
London
yeah the time_step/8 makes it go up but it goes 1459..1460...1461...1462 ect, i want it to be like a clock and go 1459..1500...1501... sorry if im not clear.

Re: Time display [Re: Widi] #324883
05/23/10 20:10
05/23/10 20:10
Joined: Nov 2009
Posts: 89
Germany, NRW
T
TrackingKeks Offline
Junior Member
TrackingKeks  Offline
Junior Member
T

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 Offline
Serious User
Widi  Offline
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:
Code:
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
W
wdlmaster Offline
Member
wdlmaster  Offline
Member
W

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:

Code:
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: wdlmaster] #324906
05/23/10 21:33
05/23/10 21:33
Joined: Aug 2007
Posts: 1,922
Schweiz
Widi Offline
Serious User
Widi  Offline
Serious User

Joined: Aug 2007
Posts: 1,922
Schweiz
wdlmasters code is better than mine, once again wink cry

Re: Time display [Re: Widi] #324957
05/24/10 05:04
05/24/10 05:04
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Give this a try. Its more in keeping with your original concept.
Code:
...
   // 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
Page 1 of 2 1 2

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1