In this lesson we will transport ourselves through time! By clicking on different characters we will find ourselves surrounded by dinosaurs or looking at a space city!
Create a new Scratch project and delete the cat sprite.
Go to the Scratch website using the link below and click on the 'Create' link in the blue bar at the top.
By default, each new project starts with the cat sprite already added. To delete the cat click on the x in the blue circle beside the cat in the sprite list.
We'll start off in modern times so add the 'Hall' backdrop from the backdrop library (as this is a modern scene).
To add a backdrop from the backdrop library follow these steps:
You can use search box or the filter links (Fantasy, Music, Sports etc) to locate your backdrop.
Add the sprite called 'Dee' from the sprite library.
Drag the sprite to the left of the stage area (by holding down the left mouse button and moving your mouse).
Dee will say some instructions at the start. He will tell us how to transport to different time periods.
Add the following code to the Dee sprite:
when green flag clicked
switch costume to [dee-b v]
switch backdrop to [Hall v]
say [Hi I'm Dee and I have a time travel machine!] for [4] secs
say [Click on one of the items below to transport to that time!] for [4] secs
As there is a lot of text to put in for what the character will say, it's a good idea to learn how to copy and paste text as this will save you a lot of time!
How to copy and paste text:
To add a sprite from the sprite library follow these steps:
You can use search box or the filter links (Animals, People, Fantasy etc) to locate your sprite.
We're going to create and use a variable called 'time' to set what time period to transport to. When we choose a time period, we will set the value of the 'time' variable and that will change the scene and characters based to that chosen time period.
After you create the variable, add the set [time] to now block to the boy sprite, underneath the when clicked block.
when green flag clicked
set [time v] to [now] // insert this block here
switch costume to [dee-b v]
switch backdrop to [Hall v]
say [Hi I'm Dee and I have a time travel machine!] for [4] secs
say [Click on one of the items below to transport to that time!] for [4] secs
In the Variables palette, create a new variable by clicking the 'Make a Variable' button.
Once you click this button a box will appear asking what you want to call your variable. Give it a name that reminds you what you will be using it for. For example, if you wanted to keep track of your score in a game, you would create a variable called 'score'.
We're going to transport to different time periods by clicking on particular sprites. The first time period we're going to code is the time when dinosaurs roamed the earth.
Add the 'Dinosaur2' sprite from the sprite library, drag it to the bottom left of the stage area and add this code to it:
when green flag clicked
set size to [50] %
when this sprite clicked
set [time v] to [dinos]
switch backdrop to [Jurassic v]
To add a sprite from the sprite library follow these steps:
You can use search box or the filter links (Animals, People, Fantasy etc) to locate your sprite.
Next we will add some dinosaur sprites from the sprite library that will be displayed in our Jurassic scene (and they will be hidden for any other scene).
Choose 2 dinosaur sprites from the library and add them. You will need to add the following code to both sprites.
when green flag clicked
forever
if <(time) = [dinos]> then
show
else
hide
end
Once you've added the code to both of these sprites, test it out by clicking on the green flag and the clicking on the 'Dinosaur2' sprite. The Jurassic backdrop with the 2 dinos should be showing.
To add a sprite from the sprite library follow these steps:
You can use search box or the filter links (Animals, People, Fantasy etc) to locate your sprite.
Now that you've coded the first time period that you can transport to, add more time periods using the backdrop and sprite libraries.
For each time period you will need to:
For example you could transport into the future by adding the following:
Add the following code to the Planet2 sprite:
when this sprite clicked
set [time v] to [future]
switch backdrop to [Space City 1 v]
Add the following code to the both the Kiran and Dot sprites:
when green flag clicked
forever
if <(time) = [future]> then
show
else
hide
end
Our first time period will be the time the dinosaurs roamed the earth! Add the 'Jurassic' backdrop from the backdrop library.
To add a backdrop from the backdrop library follow these steps:
You can use search box or the filter links (Fantasy, Music, Sports etc) to locate your backdrop.