Game Development Reference
In-Depth Information
character. As mentioned, the underscore character is the line continuation
character in VB. Since the language does not use a termination character,
like the semi-colon in C, it has a continuation character for when a single
line of code should span multiple lines for readability.
16. Now add the following wrapper function to AI.vb:
'This is the public wrapper. It knows about the world.
Public Sub RunAI(ByVal World As House)
World.StatusLabel.Text = CoreAI(CInt(World.AmbientUpDown.Value), _
CInt(World.SetPointUpDown.Value))
End Sub
The wrapper isolates the AI implementation from the world implementa-
tion. If how the world is implemented changes, then only the wrapper
needs to change, not the core AI routine. CInt converts the UpDown values
from decimal to integer.
17. All that remains is to connect the world to the AI. When does the AI need to
run? It needs to run upon startup and whenever either of the two tem-
peratures changes.
18. Right-click House.vb in the Solution Explorer and select View Code.
19. We need to get to the form load event. Above the code-editing pane (the big
center area) are two drop-down lists. Change the selected entry in the
drop-down list on the left from House to (House Events).
20. Change the selected entry in the drop-down list on the right from
Declarations to Load. Visual Studio takes you to the event handler or creates
the skeleton for it if it does not exist. (This procedure is useful for creating
event handlers other than the default event handler and to navigate to a
particular event handler.)
21. Change the selected entry in the left drop-down list to AmbientUpDown.
22. Change the selected entry in the right drop-down list to ValueChanged.
Visual Studio will create the skeleton for the event handler.
23. Change the selected entry in the left drop-down list to SetPointUpDown.
24. Again change the selected entry in the right drop-down list to Value-
Changed. Visual Studio will create the skeleton for this event handler.
 
Search Nedrilad ::




Custom Search