Posts: 68
Threads: 7
Joined: Dec 2004
this is the work-around for SLEEP keyword. currrently FB using straight of milliseconds measurement from the API. example below is methods to use usual SLEEP in seconds.
Code:
print "testing sleep 2 seconds"
sec = 1000
sleep 2*sec
print "wake-up now."
print
input "press ENTER to exit...",pause
= inc(¢)
Posts: 3,522
Threads: 189
Joined: Dec 2003
Milliseconds is a better idea overall
And you know..
QB:
Sleep 2
FB:
Sleep 2000
It's not that hard to translate
Posts: 48
Threads: 2
Joined: Jan 2005
BTW, that's a conversion, not a work-around.
A workaround would be more like (using QB code for fun):
A$=input$(1)
or do: loop until inkey$<>""
Because, you are working *around* the keyword SLEEP. :bounce:
ric Carr
Posts: 1,407
Threads: 117
Joined: Dec 2002
Eric Carr, the creator of Spinball here!
I found Spinball at the ABC packets back in 1999 when i started submitting there....a long time ago.
Welcome!
(FB is magic!)
Perhaps you are planning a FB port of Spinball?
And for SLEEP it was never a safe QB keyword: crashed when used with multikey routines, did'nt work compiled with QB4.0 (the thing people used before ffix).
So if we have a SLEEP with microsecond accuracy we can't complain. How many SLEEP's will you have to change in a normal program? three or four. The problem would be if v1ctor had enforced the use of LET
Antoni
Posts: 48
Threads: 2
Joined: Jan 2005
Quote:Eric Carr, the creator of Spinball here!
I found Spinball at the ABC packets back in 1999 when i started submitting there....a long time ago.
Welcome!
Thanks!
Yeah, those were the days. I actually made that game in '96, I think it was the April '96 packet.. Wow, so long ago..
Thought I would jump on the FB bandwagon. :-)
Quote:Perhaps you are planning a FB port of Spinball?
Perhaps.... I was thinking something 3dish... Using sdl / opengl.. Maybe I'll make a 3D (still 2D levels and gameplay) Spinball remake... I just don't have too much free time these days. What with job, consulting on the side, and .... playing computer games.. ..
I'm also addin some new features to that cool FBIde program written by VonGodric. That's C++ though, not basic.
ric Carr
Posts: 285
Threads: 70
Joined: Feb 2005
I have found SLEEP n unreliable after using PLAY etc. If others have similar difficulties try using SOUND 30000, n to create inadible sound but a simlar delay. This is how I created a menu of all the PLAY tunes someone kindly uploaded from the old ABC site.
Gordon
Posts: 1,439
Threads: 15
Joined: Apr 2003
FB doesn't have PLAY or SOUND... :???:
Posts: 133
Threads: 19
Joined: Jan 2005
Quote:BTW, that's a conversion, not a work-around.
A workaround would be more like (using QB code for fun):
A$=input$(1)
or do: loop until inkey$<>""
Because, you are working *around* the keyword SLEEP. :bounce:
Hmm...
Code:
secondstowait = 2
t! = TIMER
DO:LOOP WHILE t!+secondstowait>TIMER
Any objections versus this "workaround"?
EDIT: I like this one better than sleep because inside the do loop loop you can do something, like updating sound or GFX, while sleep is just sitting there playing pocket billard.
color=red]Look at you, Hacker. A pathetic creature of meat and bone, panting and sweating as you run through my corridors. How can you challenge a perfect, immortal machine?" - Shodan, AI at Citadel Station orbiting Earth[/color]
Posts: 48
Threads: 2
Joined: Jan 2005
Quote:EDIT: I like this one better than sleep because inside the do loop loop you can do something, like updating sound or GFX, while sleep is just sitting there playing pocket billard.
Yes, idealy you would never use sleep, you would loop and capture keypresses in your main game loop. Basically an advanced version of what you posted. :-)
I rarely used sleep, maybe to pause at some text screen but that's about it.
Eric
ric Carr
Posts: 6,419
Threads: 74
Joined: Mar 2002
I've found that in QB, SLEEP 2 pauses two seconds but you can press a key and the pause will be broken, so you can use it as a "timed 'press a key'".
So I took this old code of mine which used a SLEEP seconds% and changed it to SLEEP seconds% * 1000 in FB... But alas, pressing a key didn't break the pause. I have yet to isolate a SLEEP command and try it to check if it is a different behaviour between QB and FB or simply my bad program logic.