Section 5Keyboard Control of Your UFO

Key Press Detection 62Using a While Loop to Run Your Game 62Moving the UFO When Keys Are Pressed 63Exercise: Turbocharge Your UFO 65

The example in this section is much easier than the last one, and we're sure you'll find it more fun, too: You get to control the movement of your UFO yourself by pressing keys on the keyboard! Let's start with all of the program instructions:

image

image

There are only two new concepts to understand in this program: using a While loop instead of a For loop, and detecting keys that the user ...

Get Learn to Program with Phrogram™!: A Guide to Learning Through Game Programming Using the Latest Version of Kids Programming Language now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.