Scratch
Beginner
40 mins
Teacher/Student led
+140 XP

Conditionals and Events in Scratch

Students use PRIMM to build Attack of the Dots in Scratch, adding if decisions and key events so a spinning disc reacts differently when matching and non-matching coloured dots hit it, and they treat cloned ball scripts as reusable modules.

Teacher Class Feed

Load previous activity

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

    Illustration for Start: what we're buildingYou can already make sprites move and respond in Scratch. Today you will build Attack of the Dots: a spinning disc in the middle, coloured dots that clone and move in, and if decisions so the game reacts when a dot hits the matching colour.

    You will work step by step at your device: predict, build, run, and fix.

    2 - Introduction ~3 mins

    Welcome to the 'Attack of the Dots' game project! In this exciting lesson, you will learn how to create a fun and interactive game using Scratch. You will control a colored disc in the middle of the screen, and your mission is to match the color of the disc with the colored dots that are attacking it. You will learn how to make the disc spin, clone the attacking dots, and detect the color of the dots. Let's get started and have some fun!


    3 - Remix the Starter Project ~2 mins

    We've created a starter project that has some custom sprites for this game.

    Go to the starter project at the below link and click on the Remix button to create a copy of the project.

    https://scratch.mit.edu/projects/281652790/editor/


    4 - Make the Disc Spin ~4 mins

    In this game coloured balls will move towards the disc in the middle. You need to spin the wheel to match the colour of each ball as it hits the wheel. So we'll program the left and right arrow keys on our keyboard to spin the wheel in each direction.

    Add the following code to the 'wheel' sprite:

    when green flag clicked go to x[0] y [0] // place it in the center set size to [30]% // resize the wheel to 30% forever if < key (left arrow v) pressed? > then turn ccw (3) degrees // turn anti clockwise end if < key (right arrow v) pressed? > then turn cw (3) degrees // turn clockwise end end

    Once you've added the code, click the green flag and test if your arrow keys spin the ball!

    5 - Clone the Ball ~3 mins

    In the game, the balls should appear every few seconds, in a random position and start moving towards the wheel.

    Add the following code to the green ball called 'Sprite1':

    when green flag clicked hide forever wait (pick random (4) to (8)) seconds // wait a random number of seconds create clone of (myself v) // create the clone end when I start as a clone go to (random position v) // start in a random position point towards (wheel v) // point in the direction of the wheel show

    Click on the green flag and the green balls should start appearing in random places.

    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