Game Development Reference
Name property to FpsLabel. Change the Text property to FPS. Change the
Anchor property to Top, Right. This label will show how fast our animation
2. Drag a Button control from the Toolbox to the lower-left corner of the form.
Change its Name property to StartButton. Change its Text property to Start.
Change its Anchor property to Bottom, Left. This button will start the
3. Drag another Button control from the Toolbox and place it next to the Start
button. Change its Name property to StopButton. Change its Text property
to Stop. Change its Anchor property to Bottom, Left. This button will stop
4. Drag a Timer control from the Toolbox onto the form. When you let go, it
will jump to the bottom of the editing pane. Timers have no visible user
interface elements, so they are held at the bottom. Change the Name
property of the timer to AnimationTimer.
5. Drag another Timer control to the form. Change its Name property to
ThinkTimer. We do not need it to move the vehicles, but we want it on the
form so that we do not have to revisit some of the code we are about to write.
6. Drag a HScrollBar control from the Toolbox to the bottom-right corner of
the form. Change its Name property to PanScrollBar. Change the Small-
Change property to 10. We will resize it later, after the rest of the controls are
on the form.
7. Drag a Label control to the form and place it to the right of the Stop button.
Change the Name property to RefLabel.
We need to track some data if we are going to compute the frame rate. We also
need to set the frame rate. Once we do that we can turn on the Start and Stop
buttons and ask our vehicles to move. Switch to the Code view of Road.vb and
add the following code inside the class:
'Some constants we can tweak.
Dim FrameRate As Integer = 6
Dim ThinkRate As Integer = 2
'We need a start time to compute frame rate.
Dim startTime As Date
Dim framecount As Integer