Scratch
Beginner
40 mins
Teacher/Student led
+170 XP

Code a Game That Uses Your Model

Students load their trained Teachable Machine image model into Scratch and build a rock–paper–scissors game against the computer, then tune the confidence threshold and test what happens when it is set too low or too high.

Teacher Class Feed

Load previous activity

    1 - Start: What We're Building ~4 mins

    Illustration for Start: what we're buildingYou can already train an image model for hand gestures. Today in Scratch you will load that model into a rock, paper, scissors game and play against the computer.

    Before you build, think: what might go wrong if the model is only slightly sure about a gesture? Open the project space you saved earlier and get ready to build step by step: predict, run, investigate, modify, then make it your own.

    2 - Introduction ~2 mins

    In this lesson, you will create a fun Rock, Paper, Scissors game using Scratch and Google Teachable Machine.

    You will learn how to use your Teachable Machine Image model with rock, paper, and scissors hand gestures to play against the computer.

    If you don't have a Teachable Machine Image model, don't worry! You can use the provided model.


    3 - Setup Scratch and Tm2scratch ~3 mins

    Go to https://stretch3.github.io/ and start a new Scratch project and delete the Cat sprite.

    Then, add the TM2Scratch extension by clicking on the Extensions button at the bottom left corner of the screen and selecting TM2Scratch. This extension allows you to use Google Teachable Machine Image models in your Scratch projects.

    When you add this extension, it will automatically try and use your computer's camera. If necessary, click on 'Allow' to give it permission to use your camera. You should see what the camera is showing in the stage area.



    4 - Add a Sprite ~2 mins

    Add a new sprite to the project that will represent the computer's choice in the game. You can choose any sprite you like, but for this example, we'll use the 'Gobo' sprite.


    5 - Create Variables ~2 mins

    Create three new variables:

    • playerChoice - to store the player's choice.
    • computerChoice - to store the computer's choice.
    • result - to store the result of the game.
    123learn · Online learning platform

    Unlock the full learning experience

    You're previewing this lesson. Get full access to this lesson and hundreds more — each one ready to teach, with interactive activities, printable resources and pupil progress tracking built in.

    Hundreds of curriculum-aligned lessons
    Interactive activities in every lesson
    Printable resources & progress tracking
    Copyright Notice
    This lesson is copyright of Coding Ireland 2017 - 2025. 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