Game Development Reference
In-Depth Information
Private Sub StartButton_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles StartButton.Click
'Store values for computing frames per second.
startTime = Now
framecount = 0
'Initialize and enable animation.
AnimationTimer.Interval = CInt(1000 / FrameRate)
AnimationTimer.Enabled = True
'Initialize and enable AI.
ThinkTimer.Interval = CInt(1000 / ThinkRate)
ThinkTimer.Enabled = True
'Don't show FPS when running.
FpsLabel.Visible = False
'Do not scroll when running.
PanScrollBar.Enabled = False
End Sub
Private Sub StopButton_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles StopButton.Click
'Stop animation and AI.
AnimationTimer.Enabled = False
ThinkTimer.Enabled = False
'Compute frames per second.
Dim stopTime As Date = Now
Dim min As Integer = stopTime.Subtract(startTime).Minutes
Dim secs As Integer = stopTime.Subtract(startTime).Seconds + 60 * min
'Avoid a divide by zero.
If secs < 1 Then secs = 1
'Compute the rate and show it.
FpsLabel.Text = Format((framecount / secs), "0.0") & " FPS "
FpsLabel.Visible = True
'Allow scrolling.
PanScrollBar.Enabled = True
End Sub
The buttons turn the timers on and off. They also disable and enable the
scrollbar. Once we get the vehicles moving, we will switch from a static ground
view of the vehicles going by to a vehicle-relative view so that we can stay with a
 
Search Nedrilad ::




Custom Search