Game Development Reference
In-Depth Information
will need the minefield to be more than 900 pixels wide and 480 pixels tall.
We will put the control panel below the mines, so the form will have to be even
taller.
Launch Visual Basic and create a project called Mines.
1. Change the name of Form1 to PlayingField.vb and its Text property to
Mines.
2. Resize the form to around 920 by at least 650 pixels. Final sizing will depend
on your Windows settings and can be adjusted later. If you have room to
make it taller, it is a good idea to do that now.
3. Drag a Panel control to the form from the Toolbox. This will be our control
panel. Change its Location property to 0,490 so that it will be below the
minefield on the form.
4. Resize the panel so that it takes up all of the bottom of the form.
5. Change the BackColor property to White.
6. Open the File menu and choose Save All and choose an appropriate location
on your system.
Your screen should resemble Figure 4.1. The actual proportions will vary
according to the resolution of your monitor.
This gives us rudimentary versions of two of our three main components of the
game.
Squares
We will base our squares on the Button control. We will create a class called
Square , and it can inherit from the Windows Button control. Playing Minesweeper
involves a lot of clicking and right-clicking, Button controls have all the events we
would need to handle the user input and display the results. Our Square class will
extend the Button class and add the custom data and code we need.
Sofar,wehavedraggedallthecontrolsthatwehaveplacedontheformsfrom
theToolbox,butthat'snottheonlywaytogetthemthere.Herewewillcreate
Square objects and place them on the form using code. We will write the Square
classandaddjustenoughcodetotestthatwecangetSquareobjectsonto
the form.
 
Search Nedrilad ::




Custom Search