Programming stories
Programming with Scratch Jr - Lesson 4
Objectives
- To program scene changes in an animation
- To use logical reasoning to predict the behaviour of simple programs
Lesson Resources
- Lesson slides
- (if using tablets) A way to display your tablet on your classroom screen (Reflector 2, AirServer, Dongle)
Lesson 1 - Movement, Looks, Control
Lesson 2 - Multi-sprite animations
Lesson 3 - Triggering actions
Lesson 4 - Programming stories
Lesson 5 & 6 - Programming games
Introduction
Recap the last lesson. Can you remember what these different trigger blocks do? What did this red block mean? How did we make characters interact with each other at the correct time?
Main task
This week we are going to try a tell a story that involves more than one scene.
The + button on the right of the screen lets you add another scene to your project. It behaves almost like it’s another project on its own but scenes can be linked together. You’ll need to add a background and sprites to this scene too. But then you’ll see both scene in a list on the right.
You’ll also see a new red block appear! This, like the other red blocks, has to go at the end of an algorithm. It switches you to the scene with the number it shows. It even has a thumbnail picture of the scene to help you see where it will take you.
Let’s look at our example animation from the last lesson where the two characters were talking. We can change the final bit of the girl’s code (after she went off to look for her book) to add a switch scene block, so the story can continue!
Then go to scene two and continue your coding, starting with a green flag block (this will automatically run when it switches to scene 2)
Here’s a video showing the new version with a second scene.
But to help the students get the hang of switching scenes their story doesn’t have to be so complicated with a lot of back and forth conversations. For some students, leaving messages out for now might be useful, but encourage most students to try and include at least one send and receive message function to build on the last lesson.
Below are a couple more examples, but feel free to create your own as well when demonstrating for you pupils.
A simple one-character animation like this one can work well.
‘Scratch’s day at school’
In this example we start with Scratch the cat and a rocket (he’s off to the moon!). The first algorithm is for the cat and is mainly speech, with a bit of movement and a send orange message block at the end. The message is sent to the rocket sprite.
The rocket receives the orange message, takes off into the sky and hides, then it switches to scene 2, in space.
In scene two just the rocket sprite is programmed to move around the screen (quickly) as Scratch goes on his journey to the moon, then it hides and switches to scene 3.
In scene 3 the rocket slowly lands on the surface of the moon. Scratch is hidden until the red message tells him to show (as he gets out of the rocket).
Once Scratch has appeared (see below image) he speaks, jumps, speaks and moves around the moon scene, before speaking again and then hiding (as he gets back into the rocket), then a yellow message is sent to the rocket. The rocket receives the message (see image above) and, with the speed set to fast, moves up to take off, hides and the code (and animation) is ended.
You can see the full animation in this video
Ask the students to have a go at creating their own multi-scene story. All students should aim to create at least two scenes, some will create more and will include messaging.
Plenary
Ask the students to pair up and show each other their animated stories. Ask them afterward, did they use more than one scene? Did it switch at the right time? Did they use messaging to make things happen?
If you have the facility, choose a student that is happy to demonstrate their story, and connect their tablet to the big screen. Show the class their story but run it in full-screen mode. Show it all the way through and then re-show it, but the second time, ask the students to look out for where you think messages might have been used. Did the scenes switch well? Did it make sense as a short story?
Did anything go wrong when you were making your own story? How did you debug it?
In our next lesson, we are going to be moving on from animations into making and programming simple games.