Sometimes you want to make something in Scratch that isn’t a game per se but more like an interactive story. In this article, we’ll be covering some of the tricks and techniques that make it easy to tell a story! Spoiler: there’re a lot of messages.
We’ll start with the easiest way to make a story in Scratch: hard code a bunch of character actions with explicit timings.
I’m going to start by picking a couple of characters for our small work of theater.
They each have a small script telling them what to do.
The dinosaur’s code looks like:
And the dragon’s looks like:
Now we can continue telling a story this way, syncing up the thinking, saying, and motion with explicit wait commands—this works fine if there’s only a few bits of dialogue in your story but what if you want to add to or change the story? You’re going to have to recalculate each of the waits.
Suggested experiment: try making a story with more than three back and forth bits of dialogue between two characters. Then add an extra line into the middle of the dialogue. What all do you have to change to keep the rest working? You can start by finishing our simple story of a dragon meeting their mom again after many years.
Let’s try a different way of telling the story that I think is easier once you want a lot of dialogue: using messages to synchronize the actions of our characters!
Every time we’d use a wait block to cause a character to wait to do the next thing, instead we’ll send messages back and forth between the characters.
Here’s the new code of the dinosaur:
And the code for the dragon:
This might seem like more work initially than using wait blocks but it’s going to be a lot easier to change dialogue than before. If we wanted to add another line of dialogue in the middle of one of the exchanges we can just add it directly and not worry about fixing anything else to synchronize!
If I change the dragon’s dialogue to:
I don’t have to change anything else in order to keep all the actions synchronized.
Even if this trick doesn’t seem like a big deal for something small, it’s going to help out a lot as you develop large stories that involve multiple characters. So let’s add a little something more: I’m going to have a third character enter the scene at the end.
I made a new dinosaur sprite and then went ahead and added some new code to it:
My gosh, what a plot twist!! Where is this story going?
Feel free to start from this story, which is linked at the end of the article, to make something new!
The last thing I’d like to mention is that you can also use the when backdrop switches to and switch backdrop to blocks, found in Events and Looks respectively, to synchronize all the characters across scene changes rather than just between back and forth parts of dialogue.