Copyright
by
The
Goodheart-Willcox
Co.,
Inc.
164 Introduction to Video Game Design
64. Enter 1 in the Value: text box.
65. Click in the Operation: text box and select Equal to from the shortcut menu.
In earlier lessons, you learned how qualifiers work. This test-variable action is the qualifier
for the rest of the actions needed, which will be in a block of code. If the qualifier does not show
the value of VAR_One_Stick equal to 1, then the block of code will not be executed. The first
action in the block of code is to allow the player to place a stick of dynamite when the space bar
is pressed.
66. Drag the Start Block button from the Control tab and drop it into the Actions: column
below the test-variable qualifi er.
67. Drag the Create Instance button from the Main 1 tab and drop it into the Actions:
column below the Start of a block entry.
68. In the Create Instance dialog box, program the action such that an OBJ_Dynamite_
Stick object will be created at (16,–16) relative to the OBJ_Avatar object.
69. Drag the Set Variable button and drop it into the Actions: column at the bottom of the
block of code.
70. In the Set Variable dialog box, program the action to set the value of the variable VAR_
One_Stick to 0. This is needed because otherwise the player would be able to place an
unlimited number of sticks of dynamite without having to go back to the dynamite pack.
71. Drag the End Block button from the Control tab and drop it into the Actions: column
to close the block of code.
72. Test play the game. You will notice a bug with the sticks of dynamite, which will be
discussed in the next section.
73. Save your work.
Level B Bug
When you test played the game, you should have noticed you can place an unlimited
number of sticks of dynamite, even before you run into the dynamite pack. This is considered
a level B bug. See Figure 10-9. Remember, when you first created programming for placing
a stick of dynamite, pressing the space bar was the event. However, the programming you just
created with the variable VAR_One_Stick also has an event of pressing the space bar to place a
stick of dynamite.
Select the
operation
Make sure the
variable is
spelled correctly
Enter the value
to test
Figure 10-8
Start
Block
End
Block
Create
Instance
Set
Variable
Run the
Game
Previous Page Next Page