Initializing the Characters

Initializing the characters is relatively straightforward. The only tricky part is that I save two of the characters in the character object array, Player. Listing 14.12 shows the routine.

Listing 14.12: PlayerInit Routine in I’m Thinking of a Color

Private Sub PlayerInit()
Dim p As Integer
Agent1.Characters.Load Combo2.Text, Text1.Text & Combo2.Text & “.acs”
Set TheHost = Agent1.Characters(Combo2.Text)
p = 1
If Combo2.Text <> “Genie” Then
   Agent1.Characters.Load “Genie”, Text1.Text & “genie.acs”
   Set Player(p) = Agent1.Characters(“Genie”)
   p = p + 1
End If
If Combo2.Text <> “Merlin” Then
   Agent1.Characters.Load “Merlin”, Text1.Text & “merlin.acs”
   Set Player(p) = Agent1.Characters(“Merlin”)
   p = p + 1
End If
If Combo2.Text <> “Robby” Then
   Agent1.Characters.Load “robby”, Text1.Text & “robby.acs”
   Set Player(p) = Agent1.Characters(“Robby”)
End If
AddCommands
PlayerInitialized = True
End Sub

Note that only Player(1) and Player(2) are valid. Player(0) is a placeholder for the human player. This way, if I find another character I wish to include, I can add another player without disturbing the logic.

© 1998 SYBEX Inc. All rights reserved.