Game Development Reference
In-Depth Information
thinking. Of course, the Monster object will have a button the user can click to
make it think.
Creating the MonsterAI Project
The Monster object will be our only Windows form. We will add numerous
classes to implement the states and transitions. If we were going to make more
than one kind of monster, we would create a class for general monsters first. Each
different kind of monster would inherit from the general class. We would reuse
the bulk of the software that way. Using inheritance this way is straightforward
and easy to understand. Commercial games tend to use a more complex, highly
data-driven approach. Since we are only going to do one kind of monster,
however, we will not bother generalizing it for reuse. Writing for reuse rarely
works unless there are two or better yet three different uses implemented when
the software is first written.
1. Launch Visual Basic.
2. Create a new Windows Forms Application project and name it MonsterAI.
3. In the Solution Explorer window, rename Form1.vb to Monster.vb.
4. Click the form in the editing pane and change the Text property to Monster.
5. Resize the form to make it much wider.
6. Open the File menu and click Save All. At this point your project should
resemble Figure 3.3. We are going to put the user inputs on the left side of
the Monster form and the output of what the monster is thinking on the
right side of the form.
7. We can make short work of the user interface from here. By studying the
transitions, we see that the monster needs to be able to know if it can detect
players and if it has high or low health. We also need to give the monster a
place to show us what it is thinking. After we add the controls that make up
the visual elements, we will add the code that makes them work. First,
drag a CheckBox control from the Toolbox to the top-left corner of the
Monster form.
8. Change the Text property of the CheckBox control to Sees Players.
9. Change the Name to SeesPlayersCheckBox.
 
 
Search Nedrilad ::




Custom Search