Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Is there a way to set a delay time til next line?
#1
I want to make a delay of approx 1.5 seconds between a few lines of code, im sure iv done this before so i know theres a way, but for the love of god i cant remember how. :roll:
-p
Reply
#2
Use the TIMER lik this:

Code:
Time! = TIMER
DO: LOOP UNTIL TIMER > (Time! + 1.5)

That's all you gotta do :wink:
crapyard / Smile Cheerful Software
[Image: Cheerful.gif]


"All your base are belong to us"
Reply
#3
Its also a good idea to put it in a subroutine, makes the code clearer:

Code:
SUB Delay(seconds!)
   Time! = TIMER
   DO: LOOP UNTIL TIMER > (Time! + seconds!)
END SUB

And then just use

Code:
Delay 1.5

if you want to delay for 1.5 secs.
url=http://www.copy-pasta.com]CopyPasta[/url] - FilePasta
Reply
#4
Good idea, Zap!

DON'T USE THIS : however, as I found out :lol:

time$ = "00:00"
do:loop until time$ = "00:02"

ARGH it resets the system clock!!??!?!!!! lol so don't use that, I would use ZAP's idea if I were you. Good thinking, Zap!
ovaProgramming.

One night I had a dream where I was breaking balls. The next morning, BALLSBREAKER was born.

Quote: Excellent. Now you can have things without paying for them.

BALLSBREAKER 2
~-_-Status Report-_-~
Engine: 94%
Graphics: 95%
Sound: 100%
A Severe Error has crippled BB2 for the time being... I have to figure it out, but until then you won't see much of it Sad.
-----------------------------
Reply
#5
If you people will start using the TIMER for that kind of task, take into consideration the fact that the TIMER will reset after midnight, so if you start using the delay at, let's say 23:59:59, and the delay is set to one or two seconds, the condition LOOP UNTIL TIMER > (Time! + seconds!) will never be fulfilled.

An old sub of mine...

Code:
SUB Aguanta (num!)

Now! = TIMER
o! = TIMER + num!

DO WHILE TIMER < o!
IF Now! > TIMER THEN o! = o! - 86400
LOOP

END SUB

While basically the same, if the aforementioned situation occurs the "start" time will be substracted by 86400. Why that number? 24 hours in a day, 1440 minutes in a day... 86400 seconds in a day.

*sigh*
img]http://usuarios.vtr.net/~disaster/sigs/annoyizer.php[/img]
Reply
#6
how would you display a timer counting down on the screen? :???:
the mind is a beautiful thing, use it and make the world a more beautiful place.
Reply
#7
each second?

There are many ways. For example using SLEEP 1, although that would not give exact seconds as the rest of the code takes time:

Code:
' crappy, easy sollution
CLS
PRINT "10 seconts to lift off"
locate 2,1:PRINT " 10"
FOR i%=9 TO 0 STEP -1
   SLEEP 1
   LOCATE 2,1:PRINT i%
NEXT i%
PRINT "LIFT OFF!!"

Using timer should give a more accurate sollution .Without taking in account HD's sollution to midnight issue, the code is as follows:

Code:
' Better sollution
CLS
PRINT "10 seconds to lift off"
LOCATE 2,1:PRINT " 10"
FOR i%=9 TO 0 STEP -1
   t!= TIMER
   WHILE TIMER<t!+1:WEND
   LOCATE 2,1:PRINT i%
NEXT i%
PRINT "LIFT OFF!!"

I'm sure that someone can come with another, weirdest sollution Smile
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)