Code: Select all
t = timer: Do: Loop while t > timer
Any help is appreciated.
Code: Select all
t = timer: Do: Loop while t > timer
Code: Select all
for x = 1 to num_of_ms
sleep 1
next x
Timer resolution isn't 1 millisecond. It can vary anywhere between 5-50ms.
Code: Select all
dim as integer i
dim as double t,tot
for i = 1 to 1000
t = timer
sleep 1
tot += timer - t
next
print using "sleep resolution = ##.###ms";tot
sleep
Code: Select all
'' How many Frames Per Second we want
Dim as integer FPS = 60
'' Holds how long a frame is
Dim as Double SingleFrame = ( 1 / FPS )
'' Holds the time of the last frame
Dim as Double LastTime = Timer
'' Main Loop
Do
'' Loop until one frame has passed by
Do
'' Save CPU while waiting for the frame to pass
Sleep 1, 1
Loop until ( Timer - LastTime ) >= SingleFrame
'' Print our estimated fps ( 1 / Amountoftimeframetook )
locate 1, 1
Print "Estimated FPS: " & ( 1 / ( Timer - LastTime ) )
'' Save the new time in our variable for comparison
LastTime = Timer
Loop until Multikey(&h01)
Since no one is answering the API question I assume no one cares.
Code: Select all
#include "windows.bi"
'' In winbase.bi the Windows Sleep function has been
'' renamed to to Sleep_, I assume to avoid a name
'' conflict with the FB Sleep function.
dim as integer i
dim as double t,tot
for i = 1 to 1000
t = timer
Sleep_ 1
tot += timer - t
next
print using "Sleep_ resolution = ##.###ms";tot
sleep
Code: Select all
t = Timer + 2: Do: Loop While t > Timer
Code: Select all
t = Timer + 2: Do: Sleep 1: Loop While t > Timer
Users browsing this forum: No registered users and 13 guests