Scratch
Easy
60 mins
445 points
What you need:
  • Computer/laptop

Time Travel

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!

This message will be visible to everyone. Send

    This code along has finished! ⌚

    You can watch it back by playing the video!

    The code along is open for everyone to join in but if you would like to earn the points and badges please join our club!

    1 - Create a new Scratch project

    Create a new Scratch project and delete the cat sprite.

    2 - Add the hall backdrop

    We'll start off in modern times so add the 'Hall' backdrop from the backdrop library (as this is a modern scene).


    3 - Add the boy sprite

    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:

    1. Select the text you wish to copy by pointing your mouse just to the left of it, holding down the left mouse button and moving your mouse to select the text then release the left mouse button.
    2. Once your text is selected it should appear highlighted.
    3. Now hold down the 'Ctrl' button and press the 'C' button once. This will copy your text into your computer's memory.
    4. Click into the textbox you wish to paste your text.
    5. Hold down the 'Ctrl' button and press the 'V' button once. This will paste in your copied text.


    4 - Create a variable called 'time'

    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


    6 - Add a dinosaur sprite

    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]



    7 - Add two more dinosaur sprites

    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.




    8 - Add more time periods!

    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:

    1. Add a backdrop from the backdrop library
    2. Add a sprite that will transport you when you click it
    3. Add sprites to appear when the above sprite is clicked

    For example you could transport into the future by adding the following:

    • Backdrop library > Space City 1
    • Sprite library > Planet2
    • Sprite library > Kiran
    • Sprite library > Dot

    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


    5 - Add a Jurassic backdrop

    Our first time period will be the time the dinosaurs roamed the earth! Add the 'Jurassic' backdrop from the backdrop library.


    Join our club 😃

    Create your profile, earn points & badges and learn how to code!

    Copyright Notice
    This lesson is copyright of Coding Ireland. Unauthorised use, copying or distribution is not allowed.

    Scratch is developed by the Lifelong Kindergarten Group at the MIT Media Lab. It is available for free at https://scratch.mit.edu
    🍪 Our website uses cookies to make your browsing experience better. By using our website you agree to our use of cookies. Learn more