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.

DarkBASIC Discussion / timming problems

Author
Message
AlexI
20
Years of Service
User Offline
Joined: 31st Dec 2004
Location: UK
Posted: 22nd Mar 2005 03:00 Edited at: 22nd Mar 2005 03:05
i have got alot of things im my program that i would like to happen durring the game play like objects after a ceterain amount of time apperaing or timed objectives. at the moment i use the wait command but the whole game stops for the amount of time set is there any way to set a timer instead of the wait command i have thought of a way but in case there is anorther less code wasting way then pleas tell me

here is my way for a timer

BatVink
Moderator
22
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 22nd Mar 2005 04:30 Edited at: 22nd Mar 2005 04:31
Timer() returns an integer value representing milliseconds. So you can save this to a variable.

MyTime = Timer()

You can now get the elapsed time since the last save, in milliseconds...

ElapsedTime = Timer() - MyTime

Your code is in effect replicating this, but is dependant on the user's frame rate.
WAIT does exactly that, it stops all program execution.

BatVink
AlexI
20
Years of Service
User Offline
Joined: 31st Dec 2004
Location: UK
Posted: 22nd Mar 2005 05:03
so is this right

my time = timer() starts the timer

and to use a then statmement i would do if elsped time > 5000 then...
BadMonkey91
21
Years of Service
User Offline
Joined: 13th Jan 2004
Location:
Posted: 22nd Mar 2005 23:56
I'd like to point out that without the efforts of !hi! and monkeyshine, TGC troop 280 would not have gotten to go on the big lake field trip last tuesday.

Keep up the good work guys!

AlexI
20
Years of Service
User Offline
Joined: 31st Dec 2004
Location: UK
Posted: 23rd Mar 2005 00:50
????????????????????????????????????????????????????????????????????what are you talking about. whats tgc troop 280 and what feild trip
BatVink
Moderator
22
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 23rd Mar 2005 01:28 Edited at: 23rd Mar 2005 01:30
Quote: "so is this right

my time = timer() starts the timer"


No, Timer() is always running. I believe it's actually an operating system value. If you check it right at the start of your program, it will be some random number in the thousands. That's why you save it every cycle, so you can compare it to the latest value and ascertain how many milliseconds have passed.

my time is actually myTime in my example code. It's a variable name. It could just as easily have been called Z, or Bob.

BatVink
AlexI
20
Years of Service
User Offline
Joined: 31st Dec 2004
Location: UK
Posted: 23rd Mar 2005 04:50
how do you print a varible
BatVink
Moderator
22
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 23rd Mar 2005 23:20
print var$

or

text 5,5, var$

BatVink
Los
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Location:
Posted: 23rd Mar 2005 23:54
I've found myself out that timing events is very hard, its gonna take alot to get it working. I found it difficult triggering off timers, and say, you enter the second time the clock would not be reset. IT's most probably because you A. Don't have enough variables to remember instances and switch your cases (on,off)... or B. you've gone about it the wrong way.

**Officialy has a mental illness.
" Ahh to finish something! My boy, have you ever accomplished anything? "
Sven B
20
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 24th Mar 2005 04:54
I don't agree. Working with a timer is very easy... Look at this code for example:



press returnkey to record a time, spacekey to reset the timer...

I made this in 1min 36sec
AlexI
20
Years of Service
User Offline
Joined: 31st Dec 2004
Location: UK
Posted: 24th Mar 2005 15:17
dam sven b i just finished bu timmer program and you posted yours 1st
Sven B
20
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 24th Mar 2005 16:33
sorry...
Why don't u post ur code anyway? U started this thread...

greets
AlexI
20
Years of Service
User Offline
Joined: 31st Dec 2004
Location: UK
Posted: 25th Mar 2005 01:08
well here it is and it looks like a copy of yours

Sven B
20
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 25th Mar 2005 02:24
Pretty good. You're getting the hang of it...

Well, guess we can't learn u anything new now.
AlexI
20
Years of Service
User Offline
Joined: 31st Dec 2004
Location: UK
Posted: 25th Mar 2005 19:29
thanks guys now i can carry on working on my ai for a heleicopter

Login to post a reply

Server time is: 2025-05-31 05:44:20
Your offset time is: 2025-05-31 05:44:20