|
Second/Time question
#223672
08/25/08 21:01
08/25/08 21:01
|
Joined: Aug 2007
Posts: 286
DestroyTheRunner
OP
Member
|
OP
Member
Joined: Aug 2007
Posts: 286
|
I know its noobish... but I searched over the forum but coundt find it. Simple thing, I want add 1 to the variable every second BUT without using stuff like, sleep or wait(-1) or total_secs.
here´s the example:
var seconds;
...
while(1)
{
seconds += ?? ;
wait(1);
}
I´ve tried stuff like 'seconds = time_step/16' and 'seconds = time_frame/16' but its not acuratte at all. help?
Last edited by DestroyTheRunner; 08/25/08 21:02.
|
|
|
Re: Second/Time question
[Re: delinkx]
#223722
08/26/08 08:41
08/26/08 08:41
|
cemetarycat
Unregistered
|
cemetarycat
Unregistered
|
well, since sys_seconds goes from 0 to 59...which is 1 to 60.  when sys_seconds is equal to 59 or even when sys_seconds changes again back to 0 update or add 1 to your variable.
|
|
|
Re: Second/Time question
[Re: ]
#223726
08/26/08 09:15
08/26/08 09:15
|
Joined: Jul 2008
Posts: 553 Singapore
delinkx
User
|
User
Joined: Jul 2008
Posts: 553
Singapore
|
well, since sys_seconds goes from 0 to 59...which is 1 to 60.  when sys_seconds is equal to 59 or even when sys_seconds changes again back to 0 update or add 1 to your variable. @cemetarycat: mate, he wants to count no. of seconds. ur algorithm is for updating every one minute.
|
|
|
Re: Second/Time question
[Re: delinkx]
#223729
08/26/08 09:26
08/26/08 09:26
|
cemetarycat
Unregistered
|
cemetarycat
Unregistered
|
meowwww!  now I see. cheers so get/retrive current system time at run time or perhaps when entering a function..if the algorithm is in function. assign it as start time. then count off 1000 milliseconds...since there is 1000 miliseconds in a second. Update your variable. update your start time then for new current system time. Repeat. I have done this in other languages like Blitz3d, Cobra/Cobra 3d, Pure Basic, and even Dark Basic too. But looking in the online manual and in the Predefined variables under Time total_ticks looks good. but especially the timer function
Last edited by cemetarycat; 08/26/08 09:40.
|
|
|
Re: Second/Time question
[Re: ]
#223742
08/26/08 10:17
08/26/08 10:17
|
cemetarycat
Unregistered
|
cemetarycat
Unregistered
|
okay, here is a code snippet. ////////////////////////////////////////////////////////////////////
#include <acknex.h>
#include <default.c>
////////////////////////////////////////////////////////////////////
var update_var=0;
PANEL* first_pan =
{
digits (10, 20, 2, *, 1, sys_seconds);
digits(20, 50,4, *, 1, update_var);
digits ( 70, 200, 2, *, 1, sys_hours);
digits ( 90, 200, 2, *, 1, sys_minutes);
digits ( 110, 200, 2, *, 1, sys_seconds);
flags = VISIBLE;
}
/////////////////////////////////////////////////////////////////////
function main()
{
var start_base;
video_mode = 7;
screen_color.blue = 150;
start_base=sys_seconds;
while(1)
{
if (sys_seconds != start_base)
{
update_var+=1;
start_base=sys_seconds;
}
wait(1);
}
} and kudos and cheers to delinkx.
|
|
|
Re: Second/Time question
[Re: ]
#223821
08/26/08 20:21
08/26/08 20:21
|
Joined: Aug 2007
Posts: 286
DestroyTheRunner
OP
Member
|
OP
Member
Joined: Aug 2007
Posts: 286
|
thanks for all your replies but when I said ...BUT without using stuff like, sleep or wait(-1) or total_secs.
I meant I didnt want to use any predefined variable and ,yes through math calculations like "time_step/16" as i read in another random post but doest seem to work. is this possible to without using the predefined? thanks 
|
|
|
Re: Second/Time question
[Re: DestroyTheRunner]
#223834
08/26/08 21:17
08/26/08 21:17
|
Joined: Feb 2006
Posts: 2,185
mpdeveloper_B
Expert
|
Expert
Joined: Feb 2006
Posts: 2,185
|
you will still need to use time_step because this will make it where the time is exactly the same all the time unless your framerate is less than 4 or something.
I'm assuming that you want to see the seconds like this: XX.xxx? Is that why you want it like that?
- aka Manslayer101
|
|
|
Re: Second/Time question
[Re: mpdeveloper_B]
#223843
08/26/08 22:20
08/26/08 22:20
|
Joined: Aug 2007
Posts: 286
DestroyTheRunner
OP
Member
|
OP
Member
Joined: Aug 2007
Posts: 286
|
i think im not expressing myself very clearly. Im sorry! lets start over: how can I add 1 to the variable X every second? like X += 1*every second. without using thoses 'sys_this, sys_that...' predefinedes..I know ill probably need to use time_step, i just dont want to use those SYS predefines.. 
|
|
|
|