While Keyhit waiting problems

BlitzMax Forums/BlitzMax Beginners Area/While Keyhit waiting problems

DannyD(Posted 2005) [#1]
Hi,
I have code that I want only to exit if the user presses the ESX button.So I have a main loop like so:
While NOT KeyHit(KEY_ESCAPE)
c64(MilliSecs())
Wend

This is fine but each of these functions contain while loops and while these loops are running pressing the escape key does nothing.Am I missing something here ?




Eric(Posted 2005) [#2]
Your code runs as expected... Remember that your C64 loop is 15 seconds long. If you hit the escape key and wait 15 seconds the program ends.

In your C64 Loop maybe just use something simple like
Function c64(timerval:Int)
  While timerval+15000 > MilliSecs()
	  Cls
       
 Local y=0,h
        Repeat
                h=Rand(5,60)
                SetColor Rand(255),Rand(255),Rand(255)
                DrawRect 0,y,GraphicsWidth(),h
                y:+h
        Until y>=GraphicsHeight()
	  Flip
         If KeyHit(KEY_ESCAPE) Then End  '<-------------------------------
  Wend
End Function



mudcat(Posted 2005) [#3]
{cut}
do what prvious post said


Eric(Posted 2005) [#4]
His code is adding 15000 millisecs not 1500.

15000 Millisecs is 15 seconds vs 1.5 seconds.


mudcat(Posted 2005) [#5]
I know,my mistake


Eric(Posted 2005) [#6]
:)


DannyD(Posted 2005) [#7]
Thanks.