Name: __________________________________________
Copyright
by
The
Goodheart-Willcox
Co.,
Inc.
Lesson 3 Click Ball 39
Victory Condition
The victory condition is what it takes to win the game. In the Click Ball game, the
player will win if the ball is clicked ten times. The game needs to be programmed to check each
time a point is scored to see if the total is enough to win. This procedure is called a test. In a
test, the programming looks to see if a condition is True or False. Each time the programming
tests a condition, it will return a value of True or False. In this case, the victory condition is
when True is returned for the test: is the score equal to 10 points?
110. Open the Object Properties dialog box for the OBJ_Ball object.
111. In the Event: column, select Left Pressed. This is the event that adds 1 to the player
score and plays the click sound.
112. Click the Score tab, then drag the Test Score button and drop it into the Actions:
column, Figure 3-13. The
Test Score dialog box is displayed.
113. In the Test Score dialog box, enter 10 in the Value: text box.
114. Click the select button to the right of the Operation: text box and select Equal To in the
menu that appears.
115. Click the OK button to close the Test Score dialog box and fi nish creating the action. This
action tests if the score is equal to 10 every time the ball is clicked by the player.
116. Click the Main 2 tab.
117. Locate the End Game button. Drag and drop it into the Actions: column. Make sure the
action is at the bottom of the list. If not, drag it to the bottom of the column.
This action will end the game when the score reaches 10. The action must be at the
bottom of the list because Game Maker processes the list in order from top to bottom. If, for
example, the End the game action is placed above the If score is equal to 10 action, the game
will end the first time the player clicks the ball. Save your work and test play the game.
Test
Score
Select the event
to modify
Drag the
Test Score
button and drop it in
the
Actions
column
Figure 3-13
Run the
Game
End
Game
Previous Page Next Page