• Welcome to Dark Bit Factory & Gravity.
 

20 sec timer?[BB2D]

Started by Hotshot, March 16, 2007

Previous topic - Next topic

0 Members and 0 Guests are viewing this topic.

Hotshot


Graphics 640,480,16,2
SetBuffer BackBuffer()

Time=MilliSecs()
Repeat
Text 0,0,time
Until MilliSecs() < Time + 20000 ; 20 seconds


I got the demo up and running but I want to know how do in 20 seconds timer?

I am getting abit mixed up!

cheers


Shockwave

Should work, dunno I don't have Blitz on this computer :D


Graphics 640,480,16,2
SetBuffer BackBuffer()

Time=MilliSecs()
Repeat

Text 0,0,MilliSecs()-time
Flip
Cls
Until (MilliSecs() - Time) >= 20000 ; 20 seconds
Shockwave ^ Codigos
Challenge Trophies Won:

Paul

@Hotshot you just got the < the wrong way round ;)

Graphics 640,480,16,2
SetBuffer BackBuffer()

Time=MilliSecs()
Repeat
Text 0,0,time
Until MilliSecs() > Time + 20000 ; 20 seconds
I will bite you - http://s5.bitefight.se/c.php?uid=31059
Challenge Trophies Won:

Hotshot

I nearly got it right but thank for helping and also I put
delay(1000) to slow the timer down.

that great

cheers

Shockwave

When you put your delay of 1000 in you will slow your whole program down..


There is also a problem with the code you and paul posted, you won't be able to see the timer because you never cleared the screen...

Use this instead; (not tested but if I don't know how to write a blitz program by now I should be ashamed :P )


;----------------
; Open Screen;
;----------------

Graphics 640,480,16,2
SetBuffer BackBuffer()

Global Time=MilliSecs()

;----------------
; Main Loop Repeats until 20 seconds is over or escape pressed.
;----------------

Repeat

clock()
Flip
Cls

Until (MilliSecs() - Time) >= 20000 Or KeyDown(1)

;----------------
; Display How Many Seconds Have Passed.
;----------------


Function clock()
elapsed = (MilliSecs()-time) /1000
Text 0,0,elapsed
End Function
Shockwave ^ Codigos
Challenge Trophies Won:

mike_g

Damn shockwave beat me to it....

And yeah, if you are using delay(1000), then it will also delay the rest of your program so you will only get 1 frame per second.

By dividing the time by 1000, you can chop off the milliseconds :)



Paul

works like a charm SW!
I will bite you - http://s5.bitefight.se/c.php?uid=31059
Challenge Trophies Won:

Shockwave

Thanks :)

Lol, sorry Mike. I didn't realise you were replying to him.
Let's hope that Hotshot saw the code otherwise he will have an intro with an.. erm.. Choppy frame rate ;)
Shockwave ^ Codigos
Challenge Trophies Won: