Video Game Design and Programming Concepts 132 Copyright Goodheart-Willcox Co., Inc. May not be reproduced or posted to a publicly accessible website. 97. On the event line for every 1.70 seconds, right-click in the cell below the icon for the Heart object, and click Position Set X coordinate… in the shortcut menu. The expression editor is displayed. 98. Applying what you have learned, use the expression editor to have the computer choose a random number between 0 and 5 and multiply that value by 100, as shown in Figure 10-15. The code you created results in the coordinates in the table below. Notice that only the X coordinate changes. Random Value Multiplier Resulting Value Generated Position 0 100 0 (0, 540) 1 100 100 (100, 540) 2 100 200 (200, 540) 3 100 300 (300, 540) 4 100 400 (400, 540) 5 100 500 (500, 540) 6 100 600 (600, 540) 99. Test the frame. See if the hearts now are randomly spread out when spawned. Close the game window when done testing. 100. Debug as needed. Creating Risk Now that the game has rewards, it needs to have some risk. Without risk, the player would have little interest to keep playing. 101. Display the Game Frame in the event editor. 102. Applying what you have learned, add a new event. In the New Condition dialog box, right-click on Spiko, and click Position Test position of “Spiko” in the shortcut menu. The Test Position dialog box is displayed, as shown in Figure 10-16. 103. Hover the cursor over the arrow buttons to show the help text. Note the name of each button. Run Frame Number of values from which to select Multiply by 100 Goodheart-Willcox Publisher Figure 10-15. Specifying a value instead of an object with the random function defines the range of numbers from which the computer will select starting with 0.
Previous Page Next Page