MicroWorlds EX: Create Buttons to Direct and Hit Your Golf Ball (Part 3)

Now that your Mini Golf game is all laid out, you can create four buttons — N, S, E, W — for aiming the ball. First, create a button to point the golf ball north. On the toolbar, click the Create a Button button, and then click in the workspace anywhere. In the Button dialog box, in the Label field, type N (for north) to name the button. In the Instruction field, type golfball, comma, seth 0. Leave the other two settings at Once and Visible, and then click OK to close the Button dialog box.

Repeat the previous steps to create one button each for aiming the ball E (east), S (south), and W (west).

Next it’s time to create three buttons for hitting the ball — Drive, Putt, and Tap. On the toolbar, click the Create a Button button, and the click in the workspace anywhere. In the Button dialog box, in the Label field, type Drive to name the button. In the Instruction field, type golfball, comma, glide 100 0.2. Leave the other two dialog box settings at Once and Visible, and then click OK to close the Button dialog box.

Repeat the previous steps to create one button each for Putt and Tap.

Lastly, you’ll code your golf ball to bump off one obstacle, the mountain. Part of what makes a Mini Golf game fun is the challenge of getting past the obstacles between the tee and hole.

In MicroWorlds EX, to make the golf ball turtle bounce off the obstacle turtle, switch to the Rules tab in the golfball backpack. In the OnTouching field, type rt 90 glide 20 0.05. The rt 90 command turns the golf ball turtle to the right 90 degrees. Then glide 20 0.05 moves the ball away from the obstacle by a short distance at a slow speed.

Test your commands by deliberately driving, putting, or tapping the golf ball into the obstacle and look at the result. Revise your commands as needed to create the bounce motion you want.