First off, a loop doesn't take 8-9 millisecs() to perform. I get 1090 fps with my code below. It will drop if i add more 2d stuff, but it's veeeeeeery quick. So, the millisecs method is very accurate. Check out the sample at the bottom of this post for details.
The way you usually lay out 2d drawing operations, it's been a while since i did the 2d stuff, that's why i didn't pick up on it right away :o)
The way is usually to have
a cls at the beginning, and a flip at the end.
I have put in a strobe variable. if set to one, the color is white, if set to zero, the color is black. I alternate this, using a very handy piece of code :o)
Every time that's used, it will alternate between the values of 0 and 1.
I change the color by multiplying the value of strobe by 255. This changes the color appropriately. Then a rect that fills the screen appears. You could do this fast by using your clscolor method, but i think it's simplier using the rect. Remember, this isn't a timing problem, it's a problem with the way the code was laid out. I use a slightly different method to set the timers too.
So, this should work:
The way you usually lay out 2d drawing operations, it's been a while since i did the 2d stuff, that's why i didn't pick up on it right away :o)
The way is usually to have
While Not Keyhit(1) cls ;draw stuff flip wend
a cls at the beginning, and a flip at the end.
I have put in a strobe variable. if set to one, the color is white, if set to zero, the color is black. I alternate this, using a very handy piece of code :o)
strobe = 1 - strobe
Every time that's used, it will alternate between the values of 0 and 1.
I change the color by multiplying the value of strobe by 255. This changes the color appropriately. Then a rect that fills the screen appears. You could do this fast by using your clscolor method, but i think it's simplier using the rect. Remember, this isn't a timing problem, it's a problem with the way the code was laid out. I use a slightly different method to set the timers too.
So, this should work:
Global timer=MilliSecs() hertz# = 8 Graphics 800,600 SetBuffer BackBuffer() Global wait_time# = 1000.0/hertz Global strobe = 0 While Not KeyDown(1) Cls If MilliSecs() > timer + wait_time strobe = 1 - strobe timer = MilliSecs() EndIf Color(strobe*255,strobe*255,strobe*255) Rect 0,0,800,600 ;ignore, for timing purposes only frames = frames + 1 If MilliSecs() > time+1000 Then time = MilliSecs() fps = frames frames = 0 End If Color 128,128,128 Text 20,0,"fps = "+fps Text 20,10,"millisecs to complete frame = "+(1000/fps) ; end of ignore Flip 0 Wend