beanz Magazine

Telling Interactive Stories in Scratch

Paige Bollman on Flickr

A better, smoother way to direct your theatrical masterpiece.

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.

Learn More

Our story so far

https://scratch.mit.edu/projects/256976067/

How to make stories in Scratch

https://www.youtube.com/watch?v=TJO-oI8dBTs

How to use Scratch for digital storytelling

https://www.commonsense.org/education/blog/how-to-use-scratch-for-digital-storytelling

For teachers

http://www.literacyfromscratch.org.uk/teaching/creating.htm

Make your own virtual pet in Scratch

https://wecancodeit.org/wp-content/uploads/2014/09/Make-Your-Own-Virtual-Pet-in-Scratch-r1.pdf

Scratch resources for teachers

https://www.educationworld.com/a_tech/scratch-programming-classroom-activity-ideas.shtml

Also In The February 2019 Issue

The craft world and the tech world collide in this fun, hands-on activity.

For twenty three years, since 1996, cars have used computers to control different parts of the car.

Synchronizing games with players from all around the world is no easy task.

A simple thought experiment sheds light on the dangers of AI. Can we stop the earth being buried in paperclips?

‘Files’ may be easy concepts for humans, but not for computers. What’s going on inside your operating system?

Two ways to play Minecraft with an overarching storyline. Experience the game like never before!

Helping kids fall in love with coding through Minecraft mods and Raspberry Pis.

A better, smoother way to direct your theatrical masterpiece.

How hackers can steal the messages you send over the internet, and how to tell if your communications are secure.

It’s not as simple as it seems. Can you solve this classic programming problem?

Ever wondered what happens when you connect to a website? Time to dive into the secrets of networking!

Links from the bottom of all the February 2019 articles, collected in one place for you to print, share, or bookmark.

Interesting stories about science and technology for February 2019.