Author Topic: 20 sec timer?[BB2D]  (Read 4143 times)

0 Members and 1 Guest are viewing this topic.

Offline Hotshot

  • DBF Aficionado
  • ******
  • Posts: 2114
  • Karma: 91
    • View Profile
20 sec timer?[BB2D]
« on: March 16, 2007 »
Code: [Select]
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

« Last Edit: July 21, 2007 by Shockwave »

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17414
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: 20 sec timer?
« Reply #1 on: March 16, 2007 »
Should work, dunno I don't have Blitz on this computer :D

Code: [Select]
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:

Offline Paul

  • Pentium
  • *****
  • Posts: 1490
  • Karma: 47
    • View Profile
Re: 20 sec timer?
« Reply #2 on: March 16, 2007 »
@Hotshot you just got the < the wrong way round ;)

Code: [Select]
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:

Offline Hotshot

  • DBF Aficionado
  • ******
  • Posts: 2114
  • Karma: 91
    • View Profile
Re: 20 sec timer?
« Reply #3 on: March 16, 2007 »
I nearly got it right but thank for helping and also I put
delay(1000) to slow the timer down.

that great

cheers

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17414
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: 20 sec timer?
« Reply #4 on: March 16, 2007 »
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 )

Code: [Select]
;----------------
; 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:

Offline mike_g

  • Amiga 1200
  • ****
  • Posts: 435
  • Karma: 34
    • View Profile
Re: 20 sec timer?
« Reply #5 on: March 16, 2007 »
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 :)



Offline Paul

  • Pentium
  • *****
  • Posts: 1490
  • Karma: 47
    • View Profile
Re: 20 sec timer?
« Reply #6 on: March 16, 2007 »
works like a charm SW!
I will bite you - http://s5.bitefight.se/c.php?uid=31059
Challenge Trophies Won:

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17414
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: 20 sec timer?
« Reply #7 on: March 16, 2007 »
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: