by T.Jackson (1 Submission)
Category: Games
Compatability: VB.NET
Difficulty: Unknown Difficulty
Originally Published: Wed 27th January 2010
Date Added: Mon 8th February 2021
Rating:
(1 Votes)
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
' 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
No comments have been posted about Precision regulated delay. Often enough, when people make games in Visual Basic they literally use . Why not be the first to post a comment about Precision regulated delay. Often enough, when people make games in Visual Basic they literally use .