World 2 · Events · Guide 2 of 5Free guide
What happens when things bump?
Not every event comes from your finger. Some come from the world.
Meet the bump hat
A script can wait for a moment before it runs, and that moment does not have to be your finger. This hat waits for a bump — when the car hits a wall or runs out of road. Nothing gets tapped. The bump sets the script off by itself. One character can hold two scripts at once: one that drives, and one that waits for the bump.
So this hat says: the moment the car bumps into something, run the blocks under me.
See it work
Here is the same car twice, with the same driving blocks. Watch the first one run out of road. Then watch what a second script does with that bump.
When it bumps
Nothing about the driving changed. The bump happened both times — the second car had a script waiting to catch it.
Your turn
Now you're the programmer.
The car drives itself. Can you tell it what to do when it bumps?
Start your blocks with the 💥 hat, then land the 🚗 on the 🏁.
The car already knows how to drive
Blocks
Your program
Go further
What else could a bump start?
The blocks under the 💥 hat are yours to choose. Send the car up one cell, or three, or five and watch it stop at the top of the map. The drive never changes. Change the bump script and the ending changes with it.
For grown-ups
A script that sits idle until something happens and then runs is called an event handler — the pattern behind almost every button, alert, and collision in real software.
Keep going
Next in World 2Can two characters start together? →Where this goes
Make a game other kids can play
The blocks on this page are a first taste. In a Kubrio project your kid builds a real game — powers, triggers, levels and all — and other kids get to play it.
