Waitkey() not good enough?

Blitz3D Forums/Blitz3D Beginners Area/Waitkey() not good enough?

chwaga(Posted 2007) [#1]
there's a bunch of commands to pause execution (pause) until a key,mouse button is pressed, or timer =n, how would i go about pausing until a SPECIFIC button is pressed, or a SPECIFIC variable = something?


Yahfree(Posted 2007) [#2]
Repeat
Delay 5
until somthing=somthing?

Edit: heres a example, use the Up arrow to toggle pause on and off
Graphics 500,300,16,2
SetBuffer BackBuffer()

x=50
y=50

While Not KeyHit(1)
Cls


Rect x,y,15,15,2

x=x+1

If x>480 x=0


If KeyHit(200)
pause=2
End If

While pause=2
If KeyHit(200)
pause=1
End If
If KeyHit(1)
End
End If
Delay 5
Wend

Delay 5
Flip
Wend
End



Yo! Wazzup?(Posted 2007) [#3]
How About:
Const mykey= ;scancode for key
;do stuff
;here comes the pause
While Not KeyDown(mykey)
Wend
;more stuff after the pause



jfk EO-11110(Posted 2007) [#4]
This.
While Not KeyDown(mykey)
Wend

May crash in rare cases, when high priority background tasks can't breath, therefor always add a delay 1:

While Not KeyDown(mykey)
delay 1
Wend

IT may not crash on most machines, but basicly it's bad style anyway since it will eat 100% of the CPU resources.
The crash only happened after several minutes of inactvity (so the loop was executed for several minutes), an empty loop may be used in other situations noless, eg:

While Not KeyDown(mykey) ; wait for key, may take minutes or even hours
delay 1
Wend
While KeyDown(mykey) ; wait for key release will take only seconds
Wend