; VWait Example ; ------------- Graphics 640,480,0,2 SetBuffer BackBuffer() ; VWait makes the CPU wait for the monitor's next vertical blank, so ; the loop runs once per screen refresh. It is often paired with ; "Flip False": VWait does the waiting, then Flip False shows the ; frame immediately without waiting again. use_vwait=1 While Not KeyDown(1) Cls ; Space toggles VWait on and off If KeyHit(57) Then use_vwait=1-use_vwait ; One step per loop: without VWait the loop is unthrottled ; and the square streaks across the screen x=(x+4) Mod 640 Rect x,220,40,40,True Text 0,0,"Space: toggle VWait Esc: exit" If use_vwait Then Text 0,20,"VWait ON: one loop per screen refresh" Else Text 0,20,"VWait OFF: loop runs unthrottled" EndIf ; The documented command: wait for the vertical blank If use_vwait Then VWait Flip False Wend End