big10p, there are more than 600 scanlines in 800x600. I'm not sure about the exact number, but I think there are 624 of them and they are not all visible, i.e. let's say first 12 and last 12 are not really visible on your monitor.(I'm really not sure about these numbers) . VWait will wait until last scanline is 'drawn' on screen, but in this example you are 'flipping' a little bit earlier ( anywhere after 600'th line ) and this gives you better chance to flip on time than vwait.
Here is corrected version of your last example:
Also, I forgot to tell you why you need that " If Scanline()>=0 And ScanLine()<30) ... Take this example : On some slower machine, when logic+rendertime finish just 1ms later than it's needed to be on time , Scanline will already pass 624, and will be probably between 0-30. But, this is still not too late to flip, especially if top of the screen is static picture, like in my current project. If you use vwait, you would lose that frame, because vwait will wait for scanline to became 624 again, and you will end up with less FPS. On very slow machine, however, this won't help, but you can always experiment with these values, depending of your game. Obviously, this should go in combination with tweening. ( Delta time should be fine also ).
Here is corrected version of your last example:
Graphics 800,600 SetBuffer BackBuffer() Const TargetFPS=85 timePerFrame = 1000/TargetFPS While Not KeyHit(1) frame_start = MilliSecs() Cls Rect x,0,100,600,True x = x + 10 If x > 800 Then x = 0 usedTime = MilliSecs() - frame_start remaining = timePerFrame - usedTime If remaining > 0 Then Delay(remaining) End If Repeat: Until ScanLine()>=0 And ScanLine()<30 Or ScanLine()>600 Flip False Wend End
Also, I forgot to tell you why you need that " If Scanline()>=0 And ScanLine()<30) ... Take this example : On some slower machine, when logic+rendertime finish just 1ms later than it's needed to be on time , Scanline will already pass 624, and will be probably between 0-30. But, this is still not too late to flip, especially if top of the screen is static picture, like in my current project. If you use vwait, you would lose that frame, because vwait will wait for scanline to became 624 again, and you will end up with less FPS. On very slow machine, however, this won't help, but you can always experiment with these values, depending of your game. Obviously, this should go in combination with tweening. ( Delta time should be fine also ).