Copyright
by
The
Goodheart-Willcox
Co.,
Inc.
36 Introduction to Video Game Design
Mouse Click on the Ball
You now have a bouncing ball, but nothing else. Time to add some fun to the game and
give the player a reason to play. You need to add an event:
IF the player clicks the ball with the left mouse button, THEN add a point to the
score.
Follow the steps below to program this. The Object Properties dialog box should be open. If
not, double-click on OBJ_Ball in the resource tree to open it.
79. Click the Add Event button.
80. In the Choose the Event to Add dialog box, click the Mouse button and, in the menu
that is displayed, select Left Pressed. Do not select Left Button. The Left Pressed
option is the condition when the player clicks the button. The Left Button option is the
condition when the left mouse button is being held down, not clicked.
81. In the Object Properties dialog box, click the Score tab.
82. Locate the Set Score button and drag it into the Action: column. The Set Score dialog
box is displayed.
83. In the Set Score dialog box, enter 1 in the New score: text box.
84. At the bottom of the Set Score dialog box, check the Relative check box. Then, click the
OK button to create the action.
Remember, relative means “from where it was before.” This action changes the score to
“one from where it was before.” In other words, it increases the score by one each time the ball
is clicked with the left mouse button. If you do not check the Relative check box, the score will
always be 1.
85. Close the Object Properties dialog box, saving the changes when prompted.
86. Save your work.
Select to apply the
bounce to this object
Click to select
a precision
Click to select against
what the bounce will occur
Figure 3-10
Set
Score