Chapter 5
Knowing Where You Are… and Where You’re Going
IN THIS CHAPTER
Finding and setting position and direction
Adding randomness to position and direction
Moving and turning an object
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 ...
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