Table of Contents
Using Physics with Tynker: Part 1
Tynker’s Physics Engine allows children to make fun games using properties like bounciness, collisions, and gravity without having to manually program all these complex interactions.
Penguins bouncing in zero gravity!
In a Physics game, the Actors move by themselves based on the physics properties of the environment. Here is an example of bouncing penguins in zero gravity!
How do you build a physics game with Tynker?
Start Physics
Let’s start with the basics. Start by attaching this block so that Physics is enabled as soon as you run your program.
Now when you press Play, you’ll see all your Actors falling down to the bottom of the screen. That’s because gravity is set by default to the Earth’s gravity (around 9.8 meters per second squared), and with physics enabled, they all fall down!
Set Up Gravity
Kids will love experimenting with the “set gravity to” block. By changing the two numbers (horizontal and vertical gravity), they can make objects fall to the ground with positive gravity, be suspended in zero gravity, or float upwards in negative gravity.
Adjust Bounciness
Another fun thing is to fiddle with an object’s bounciness! To make Actors more bouncy, use this block:
In Physics, the term restitution refers to an object’s bounciness. Experiment with the values and notice what happens:
- 0.2 – Normal bouncing
- 1.0 – Really bouncy, and does not slow down
- 1.2 – Superball! Gains more energy on each bounce!
By fiddling with an object’s restitution, children can make objects bounce chaotically around the screen or stop moving entirely when they hit a wall.
Define Bounding Boxes
Every Actor on the screen has a bounding box that’s used to detect collisions. By default, this is circular. If you want to build a game where you stack objects, change the bounding box to “rectangular” so they don’t roll off each other.
Add Static Platforms
Sometimes your game needs static platforms or props that you want to stay in place. In those cases, you can use this block to make sure that the platform is “static” and immovable. Setting the value to “true” will make a platform Actor immovable.
Selectively Disable Physics
Sometimes your game may have Actors that you want to program yourself, and do not want the physics engine to control. Examples of these are score widgets, or on screen button controls. Use this block to disable physics on a specific Actor.
Project Ideas
Here are some ideas for some fun physics projects:
- Simulate gravity on the earth and the moon.
- Build a project with bouncing penguins
- Use pen commands and trace the path of a falling ball
- Build a stacking game where objects fall into place
In the next article on Physics, we’ll discuss more commands that you can use to build projectile physics games like your own version of Angry Birds.
There are tons of other features of the Physics Engine that kids can explore, including density, friction, collisions, torque, angular velocity, angular and linear damping, inertia, and more!
Sample Physics Program
“Falling Trails” is a new project available in our most recent mobile release under the “Physics” section.
When linear velocity allows them to hurl angry cats toward structures to knock them over, kids are eager to dive in and figure out how it works.
We love to see what you build. Please share your projects or send us a link so we can feature them.
How Do Kids Learn the Physics Engine?
With Tynker’s home courses, kids are introduced to the Physics Engine as early as Turing’s Tower and Goblin Quest, two of our Intro to Programming courses. But to really master the Physics Engine, they should complete Cannon Crasher. And to learn how to take advantage of the Physics Engine to create more awesome games, check out our courses Gravity Sling and Ninja Runner.