Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Resetting the timer.

Author
Message
Maxx illian
21
Years of Service
User Offline
Joined: 12th May 2003
Location: United States
Posted: 23rd May 2003 00:46
Just wondering if there's anyway to reset the value of "timer()"?
It seems that it keeps going even when not in the program.
*** Maxillian Software ***
Maxx illian
21
Years of Service
User Offline
Joined: 12th May 2003
Location: United States
Posted: 23rd May 2003 02:16
OK if nobody knows then help me with this.

I want to set up a 24 hour clock in my game. I want every minute of game time to be equal to 6 seconds of real time. I want to use military time and want it to flip from 23:59 to 00:00. Ill most likely use my own graphics for the gametime. But i just need the basics right now. If anyone can help please post.

*** Maxillian Software ***
the_winch
21
Years of Service
User Offline
Joined: 1st Feb 2003
Location: Oxford, UK
Posted: 23rd May 2003 02:21
No there is not but it is easy to work around. I think the timer() command returns the number of milliseconds since midnight (or some other time) so it makes no difference if the program is running or not.
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 23rd May 2003 02:22 Edited at: 23rd May 2003 02:23
It's the time since boot.

It's easy enough to work out - you don't reset, you calculate the difference.

Maxx illian
21
Years of Service
User Offline
Joined: 12th May 2003
Location: United States
Posted: 23rd May 2003 05:38
Thanks the winch. I checked out your source code and tried to use the zero_timer = timer() command. It didnt work. Maybe you spelled it wrong?

*** Maxillian Software ***
indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 23rd May 2003 07:41
maybe your not applying yourself properly to the subject at hand.

identify each component in the small amount of code and understand what it all means instead of just passing over a part you may think is hard.




simple isnt it?

Maxx illian
21
Years of Service
User Offline
Joined: 12th May 2003
Location: United States
Posted: 23rd May 2003 14:02
Gee thanks
Its nice to ask for help and then have someone tell you that your not trying hard enough. Im doing my best,Thanks.

*** Maxillian Software ***
sicjoshsic
21
Years of Service
User Offline
Joined: 8th May 2003
Location: United Kingdom
Posted: 23rd May 2003 14:37 Edited at: 23rd May 2003 14:39
errmm..
it wouldn't matter if he did spell it wrong, its HIS variable! so long as he spells it the same throughout the program it will work

[edit]
i apologise, he DID spell it wrong! you should have been able to fix this easy though, you're really going to struggle with any kind of programming if you can't even figure this out!


sicjoshsic
21
Years of Service
User Offline
Joined: 8th May 2003
Location: United Kingdom
Posted: 23rd May 2003 14:54 Edited at: 23rd May 2003 14:55
as for your time question, try this


ok, since i can see your new to programming, i'll explain what this code does

the first line:

simply tells the program when the last second happened, and stores it

then this line (in your main loop):

finds out if the last second happened more than one sixth of a second ago (since you said you wanted one real second to be 6 game seconds) and if it is, increases the secs variable by 1 and resets the last_sec variable
NOTE: it is important to use "<=" because if you just use "=" then the program may miss that exact milisecond and the secs variable will NEVER increase

the next 2 lines should be easy to understand, they just emulate a clock. when the secs equal 60, the mins increase and the secs go back to 0

the next line just checks to see if the hours equal 24, and if so, resets them to 0, as you said you wanted it too

the last two lines you should understand simply print the time to the screen

hope this helps you

indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 23rd May 2003 15:44
sorry wasnt meant to come across that way.

if i skip bits i find it gets confusing.

IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 23rd May 2003 16:49
'option explicit'

How many of these types of bugs would it fix?
the_winch
21
Years of Service
User Offline
Joined: 1st Feb 2003
Location: Oxford, UK
Posted: 23rd May 2003 17:39
Quote: "'option explicit'

How many of these types of bugs would it fix?"


I blame the auto correct in msword. It lets you get away with bad typeing.

I would really like to see an option explicit in darkbasic as well as information on unused variables.
Maxx illian
21
Years of Service
User Offline
Joined: 12th May 2003
Location: United States
Posted: 23rd May 2003 18:50 Edited at: 23rd May 2003 20:04
Its ok indi. No prob.
As for sic. Thanks for the code. But i couldnt help but notice your little knock down. Your zero_timer = timer() I asked about was the exact same thing he already sent me. But i did notice the curr_timer = timer() - zero_timer change. I maybe new but i learn quickly.

*** Maxillian Software ***
Maxx illian
21
Years of Service
User Offline
Joined: 12th May 2003
Location: United States
Posted: 23rd May 2003 20:03
I have finished my gameclock and it's working perfectly.
Thanks all.

*** Maxillian Software ***

Login to post a reply

Server time is: 2024-11-24 15:08:24
Your offset time is: 2024-11-24 15:08:24