Copyright
by
The
Goodheart-Willcox
Co.,
Inc.
38 Introduction to Video Game Design
98. Click the OK button to close the Sound Properties dialog box.
Next, you need to program the logic statement:
IF the player clicks on the ball, THEN add one to the score AND play a sound.
You have already programmed part of this logic statement, where the score is increased when
the player clicks the ball. So, you need to add another action to this existing statement.
99. Open the Object Properties dialog box for the OBJ_Ball object.
100. In the Event: column, select Left Pressed. The action currently assigned to this event is
then displayed in the Actions: column. Currently, the only action listed is Set the score
relative to 1.
101. On the right-hand side of the Object Properties dialog box, click the Main 1 tab.
102. Locate the Play Sound button and drag it into the Actions: column, Figure 3-12. The
Play Sound dialog box is displayed.
103. In the Play Sound dialog box, click the selection button to the right of the Sound: text
box. A menu appears listing all of the sounds that have been added to the game.
104. Select the SND_Click sample in the menu.
105. Click the selection button to the right of the Loop: text box and select False from the menu.
Loop means the sound will play again after it finishes. The click sound should play only
once each time the ball is clicked, so it should not loop. False is a programming command for
“no.” To make the sound loop, choose True in the menu for “yes.”
106. Click OK in the Play Sound dialog box to fi nish creating the new action.
107. Save your work and test play the game.
108. Using similar procedures, add an appropriate sound for when the ball collides with the wall.
Remember, you will fi rst need to create the sound in Game Maker.
109. Save your work and test play the game.
Play
Sound
Select the
event to
modify
Drag a new action and drop
it in the
Actions:
column
Figure 3-12
Run the
Game
Previous Page Next Page