Lesson 1 · Creative Coding
When the green flag is clicked.
A script sitting in the scripts area does nothing at all. It's a set of instructions waiting for a reason to run.
An event is that reason. It's the thing that happens first and sets a script going.
The green flag is the most common one, but there are many: clicking a sprite, pressing a key, a sprite receiving a message. Every script you ever write needs one on top.
Here's the part that surprises people coming from paper algorithms.
You can have several scripts that all start on the same event, and they all run at the same time.
Click the green flag and the basket starts listening for keys, the mango starts falling, and the score resets — simultaneously, not one after another. Each sprite gets on with its own job.
This is why you don't need one giant script controlling everything. Give each sprite its own small script and let them run together. Programs built this way are far easier to fix.
5 more parts in this lesson
Walkthroughs, code labs, mini-games and the checkpoint quiz unlock when you buy the course.