Skip to Content
Coding For Kids For Dummies, 3rd Edition
book

Coding For Kids For Dummies, 3rd Edition

by Camille McCue
October 2025
Beginner
288 pages
5h 58m
English
For Dummies
Content preview from Coding For Kids For Dummies, 3rd Edition

CHAPTER 5

Animating with Simple Conditionals

Haunt the city! In this chapter, you’ll create a fun, side-scrolling animation that introduces you to your third big idea in coding: selection. You’ll make a cute ghost that hovers above a cityscape. The ghost appears to fly over a seemingly endless street of skyscrapers — but it’s really the buildings moving, not the ghost! The code you write executes in a selection, or “if-then” command. If a specific condition is met, then a consequence is selected for execution. In your code, each building moves slowly across the screen, and if it reaches the edge, it then hides and reappears on the other side, but with a new color and costume.

You’ll set up your scene with a background, a ghost sprite, and many building sprites. You’ll then write code so that when the user clicks on the green flag, the ghost hovers and the buildings move in a repeat loop, using selection to know when and how to reposition. With just a little math, art, and selection, you’ll have your ghostly scene coded before you can scream “Boo!”

A whimsical, dark, cartoon image of a city skyline at night. The sky is black with glowing yellow stars. A large, light-blue, ghost-like creature with a long tail is flying above the buildings. The buildings are various shades of blue and white, with illuminated windows, sitting on a strip of green grass. A dark brown bar is partially obstructing the middle of the image.

Brainstorm

Brainstorm the design of your program by thinking about the overall look of your scene. What about an airplane flying over farmland with trees and cornstalks on the ground? Or a fire-breathing dragon soaring above a bustling city of princes, princesses, witches, and wizards?

Start a New Project

Begin creating your Haunt ...

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

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Helping Kids with Coding For Dummies

Helping Kids with Coding For Dummies

Camille McCue Ph.D, Guthals
What Successful Project Managers Do

What Successful Project Managers Do

W. Scott Cameron, Jeffrey S. Russell, Edward J. Hoffman, Alexander Laufer

Publisher Resources

ISBN: 9781394359769