- Home
·
- Games
·
- Precision regulated delay. Often enough, when people make games in Visual Basic they literally use
Precision regulated delay. Often enough, when people make games in Visual Basic they literally use
Precision regulated delay. Often enough, when people make games in Visual Basic they literally use dozens (sometimes more) -- of VB's timer.
API Declarations
Private Declare Function timeBeginPeriod Lib "winmm.dll" (ByVal uPeriod As Integer) As Integer
Private ProcessStartmS As Integer
Rate Precision regulated delay. Often enough, when people make games in Visual Basic they literally use
(1(1 Vote))
' Purpose: Set 1uS resolution for timegettime
timeBeginPeriod(1)
End Sub
Private Sub regulatedDelay(ByVal mS As Integer)
Dim StartmS As Integer
Dim ElapsedmS As Integer
StartmS = timeGetTime
If ProcessStartmS <> 0 Then
mS = mS - (StartmS - ProcessStartmS)
Do While (ElapsedmS < mS)
ElapsedmS = (timeGetTime - StartmS)
Application.DoEvents()
Loop
End If
ProcessStartmS = timeGetTime()
End Sub
Private Sub runGame()
Do
Call regulatedDelay(20) ' your central delay ...
Call makeThingsHappen ' your actual game routines
Loop
End Sub
Precision regulated delay. Often enough, when people make games in Visual Basic they literally use Comments
No comments yet — be the first to post one!
Post a Comment