Chapter 5

Knowing Where You Are… and Where You’re Going

IN THIS CHAPTER

check Finding and setting position and direction

check Adding randomness to position and direction

check Moving and turning an object

check Coding an asteroid destroyer game

This chapter helps you acquire the skills you need to perform geometry tasks when programming. Specifically, you find out how to position an object and set it in motion onscreen. If your kid is writing code to create an animated game or build a model, then placing objects in different positions and moving them around is a key skill.

Here, you and your coder discover the basics of working with x and y coordinates, as well as how to point an object in any direction. We also show you how to make objects move, set the speed of objects, code some practical programs that include using randomness to scatter many objects into different positions, and determine whether two objects collide.

Acting Out Position, Unplugged

Finding out “where you are” is fundamental to creating any kind of program that involves objects onscreen. In the real world, you use a wide range of descriptions ...

Get Helping Kids with Coding For Dummies now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.