Name: __________________________________________
Copyright
by
The
Goodheart-Willcox
Co.,
Inc.
Lesson 3 Click Ball 35
Testing
While designing a game, you will want to try things out along the way to make sure
everything is working as you intended. Click the Run the Game button on the toolbar. When
the game compiles and starts, the ball will move, but it eventually travels outside of the room.
It does not bounce off of the walls as it should. In a game, just because it looks like a wall does
not mean that it will act like a wall. Remember, the “wall” is just a picture of a wall.
You now need to program the wall and ball objects to react to each other as if they were
real. This concept is called collision theory. You need to apply collision theory so the objects
act realistically during gameplay. A collision is simply when things touch, hit, or come in contact
with each other. Not all objects will react when they collide. Think about a flying game with an
airplane and clouds. You do not want the clouds to react to the airplane. It should be able to
pass right through the clouds. For the Click Ball game, you need to create a new event for:
IF the OBJ_Ball object collides with the OBJ_Wall object, THEN the OBJ_Ball
object bounces.
Follow the steps below to program this.
68. Close the game preview.
69. In the resource tree, double-click OBJ_Ball to open the Object Properties dialog box.
70. In the Object Properties dialog box, click the Add Event button.
71. In the Choose the Event to Add dialog box, click the Collision button. A menu is
displayed showing all of the available objects. Select the OBJ_Wall object for this collision.
Notice that a new event has been added to the Events: column in the Object
Properties dialog box. Each event will be listed on a separate line. Now, you must add the
action that will take place for the event.
72. On the Move tab of the Object Properties dialog box, locate the Bounce button and
drag it into the Actions: column. The Bounce dialog box is displayed.
73. Click the Self radio button so the ball will bounce, not the wall (you are adjusting the ball
object properties), Figure 3-10.
74. Click the button to the right of the Precise: text box and select Not Precisely from the
menu.
75. Click the button to the right of the Against: text box and select Solid Objects from the
menu.
Remember, the wall object is set to be a solid object. Since the ball is now set to bounce
against solid objects, if you edit the wall object and uncheck the Solid check box, the ball will
pass right through the wall.
76. Click the OK button to close the Bounce dialog box and add the action to the object
properties.
77. Test play the game. You do not need to close the Object Properties dialog box to test
play the game. After seeing how the game runs, close the game preview.
78. Save your work.
Run the
Game
Run the
Game
Bounce
Previous Page Next Page