problem calculating time

Blitz3D Forums/Blitz3D Programming/problem calculating time

Well, you could for instance check the timer after each line of code.
x# = cos(p) * 10: CheckTimer()
y# = sin(p) * 10: CheckTimer()
oval x, y, 10, 10: CheckTimer()
for i = 0 to 10
  oval rand(x), rand(y), 10, 10: CheckTimer()
next

If you want to render in several steps, you could use a Type for all your objects.
For i.TObject = Each TObject
  ShowEntity i\mesh
  RenderWorld()
  HideEntity i\mesh
  CheckTimer()
Next

In fact, using threads does the same thing. Only then with two applications. Each application gets a certain amount of processor time.

There is a wait built in the "Flip" command. The VWait waits for the ScanLine() to be zero. It avoids nasty flickering of the image.
Graphics 800, 600, 0, 3
SetBuffer BackBuffer()

repeat

p = (p + 1) mod 2
clscolor 255 * p, 255 * p, 255 * p
cls

flip false

until keyhit(1)

end

During this wait, other application can perform their tasks. Same thing goes for Delay().
To get as close to the millisecs() accuracy, you should have:
* a tight loop
* check very often
start# = MilliSecs()
Print "START"
Repeat
time# = MilliSecs()
Until time >= start + 3000
Print "STOP"
Print time# - start#
WaitKey()
End