We are going to revisit one of the topics we did earlier in the year. Do you remember The Movies, where we had the spinning wheel looking like it was going backwards?
Well we are going to do something similar over the next couple of weeks, where we will investigate and use Stop Motion, this is the same movie making technique that the Wallace and Grommet Movies are made with.
So what are we going to learn, well, we are going ot use a lot of techniques we have used before, so it is more a case of what are we going to re-learn.
- Broadcasts – to make our code smaller and neater
- Variables to simplify the code, specifically local variables.
- Speech Bubbles.
- Program Flow, there are a lot of things that need to happen and we need them to happen in the right order.
We are going to animate The Three Little Pigs and the Big Bad Wolf.
As you know this is a little story and in stories, things happen one after the other, so that is what we need our code to do as well, there is not much point having everything running from a Green Flag, we need some way to control the flow of the Program.
First we are going to need some Sprites though.
- A Wolf
- Pig One
- Pig Two
- Pig Three
- Straw House
- Wood House
- Brick House
As you know my drawing skills are excellent, so I have come up with the following:
Nice aren’t they. I’m sure you can do better.
When the Story starts there is only the Wolf, One Pig and the Straw house visible, so all the others need some code under a Green Flag to get them ready, backstage, ready for when it is their turn in the story.
The Wood House for example has just a HIDE under the Green Flag, you will need to determine what each Sprite will need under a Green Flag control. Basically anything to get it ready for the story.
On to the Stop Motion Animation.
Stop Motion is where something is moved a small bit and then a picture taken and then moved another small bit and another picture taken, until the figure has moved to where it needs to be.
We are going to do something similar, where we will set up the x and y position of the Sprite in local variables and then get another piece of code to do the actual moving, this helps to make the code a little easier to read as it splits it into smaller sections.
Here is the code for example that one of Pigs uses to move to the next House
You can see how I have split it into smaller pieces and that I have used local Variables to set the x and y positions.
You will need to figure out where on the screen you want the Sprites to go and how fast you want them to go there, that will determine the numbers that you need to use when you are SETting the xPosition and yPosition variables.
As the Wolf is kind of the main Character in the Story, we control everything from his Sprite. We do one thing after another and if we need to wait for something else to happen we use a Broadcast and Wait, this will control how the code flows from the top to the Bottom.
Here is all the code for the Wolf Sprite
Now, my code is very scrappy, there are a number of BUGs that need to be sorted out, for example when Pig One moves to the Wood House and the Wolf comes over, the Speech Bubble covers the Pig, this should be changed really.
At the end of the day, you can make your Story as simple or as complex as you like, one thing that I can tell you though, is that the more time you spend on the project the better it will end up.
You can also do real Stop Motion with a Camera and Lego, you can then import the different pictures into Scratch as either Stages or Sprites.
I did one as Stages which is up on the Scratch Web Site and here is one of the Stages from it.