Name: ___________________________________________ 131 Lesson 10 Spawning Copyright Goodheart-Willcox Co., Inc. May not be reproduced or posted to a publicly accessible website. 89. Test to see if the platforms now have holes in random locations. Note: it may take a few spawns to see all four possible platform configurations. Close the game window when done testing. 90. Debug if needed. Rewarding the Player The heart objects will be randomly generated to float above each new platform. Rewards encourage the player to do well and take risks. Right now the player gets to the heart, but nothing happens. You need to get the hearts to award points to reward the player for taking the risk to get the heart. 91. Display the Game Frame in the event editor, and program a new event to match this pseudocode: IF Spiko collides with the Heart object, THEN destroy the Heart object AND add 1 point to the player 1 score. 92. Test the frame. Check that the heart is removed and the score is adding up. Debug if needed. If the score is not adding up, be sure the code is adding to the score, not setting the score. 93. Applying what you have learned, modify an existing event to match this pseudocode: IF every 1.70 seconds, THEN create a new Heart object at (0, 540). 94. Test the frame. See if hearts are spawned. Note: the hearts will all appear on the left side, but should not overlap a platform. Close the game window when done testing. 95. Debug as needed. Setting a Random Horizontal Position The hearts are being spawned, but in a terrible position. The hearts should spawn in random locations to make the game fun and exciting. This requires the X coordinate for each heart to be a random value. However, the Y coordinate must remain the same so the hearts will always float above the platform. 96. Display the Game Frame in the event editor. Run Frame Run Frame Retrieves value from object Multiplies by 8 Goodheart-Willcox Publisher Figure 10-14. The value retrieved from the Counter_Random object will be multiplied by 8 and the result used in the programming.
Previous Page Next Page