Thanks muk and bram32.
I tried your code and I get the same errors as in mine.
bram32, do your code works for you? I modified it just to display the errors between Total time and Total sum. I can't explain the results: Total sum is usually more then the wanted time and Total time is more than Total sum! Here is the code (thanks bram32):
The other strange thing is, as muk said, the error/delay is the same for 1 sec, 60 sec or more. I'm not sure to understand your solution muk. I need to flip continuously because of the graphics. How should I wait to get millisecs without flipping?
FiNegirO
I tried your code and I get the same errors as in mine.
bram32, do your code works for you? I modified it just to display the errors between Total time and Total sum. I can't explain the results: Total sum is usually more then the wanted time and Total time is more than Total sum! Here is the code (thanks bram32):
Graphics 800, 600, 0, 2 SetBuffer BackBuffer() Dim time#(4) .up For i = 0 To 3 time#(i) = 0.0 Next init = True Repeat ;calculate time passed now# = MilliSecs() If init Then prev# = now#: inittime# = now: init = False elapsed# = now# - prev# prev# = now# ;select quadrant mx = MouseX() my = MouseY() quad = (mx > 400) + (my > 300) * 2 ;set time for selected quadrant time(quad) = time(quad) + elapsed ;graphical output Cls ;draw grid Line 400, 0, 400, 600 Line 0, 300, 800, 300 ;print out times For i = 0 To 3 Text i Mod 2 * 400 + 200, i / 2 * 300 + 150, time#(i) / 1000.0 Next ;measure total time passed tot1# = ((time(0) + time(1) + time(2) + time(3)) / 1000.0) tot2# = (MilliSecs() - inittime#) / 1000.0 ;debug output Text 0, 0, "You're in quadrant: " + quad Text 0, 20, "Total sum times: " + tot1# Text 0, 40, "Total time millisecs: " + tot2# Flip ;limit to 60 secs If tot2# >= 3.0 Then Err1# = tot2# - 3.0 Err2# = tot2# - tot1# Text 0, 60, "Error1 (Total time - 3 sec.): " + Err1# Text 0, 80, "Error2 (Tot time - Tot sum): " + Err2# Flip Exit EndIf Until KeyHit(1) Text 400, 290, "Press space to retry", True, True Text 400, 310, "Any other key to exit", True, True Flip Key = WaitKey() If Key = 32 Then Goto up End
The other strange thing is, as muk said, the error/delay is the same for 1 sec, 60 sec or more. I'm not sure to understand your solution muk. I need to flip continuously because of the graphics. How should I wait to get millisecs without flipping?
FiNegirO