CHAPTER 10
Creating a Collection and Avoidance Game
Get spacey with Space Gems! Now that you know how to move sprites around the screen, code functions, and handle variables, you’re ready to launch a cool collection and avoidance game that takes place in a galaxy (sorta) far away. In Space Gem, you’ll challenge your player to control an astronaut who will collect and transport a glowing space gem back to the home planet. But look out! A naughty robot will appear from nowhere and try to zap the astronaut and steal the gem. Your player needs to avoid the robot, and if it catches the astronaut — Game Over! And like all good space missions, you need to get the job done before time runs out.
As you work through this chapter, you’ll learn new skills in coding collisions to respond to both collection and avoidance. You’ll also explore Boolean variables as you code a logical and operator. Lastly, you'll use broadcasting to control a part of the game’s action using sprite-to-sprite communication. Now, get started on building a space adventure that’s out of this world!

Brainstorm
Your game doesn’t have to be about astronauts, robots, or space gems. You can design any hero collecting any object in any setting. Just make sure your game has a setting, a hero, one or more collectible objects, and a villain trying to stop your player from succeeding. Time to get creative — and start coding! ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access