You 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.
Keep this tight. Devices on Scratch, students logged in. Optional predict before anyone runs code: ask what might happen when a coloured dot hits a matching part of the disc versus a mismatch. Do not list blocks. Model that pairs will build step by step, then move straight to the remix.
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!
Read the project hook aloud once. Do not expand into a full demo. Point out the disc and attacking dots idea only, then send students to remix so build time is protected.
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.
Share the starter link on the board. Confirm every student clicks Remix and lands in their own copy before any coding. Beginners can use the alternate starter if you prefer a simpler asset set. Watch for students editing the original instead of a remix.
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
Model on the board: green flag, go to centre, set size, forever with two if key-pressed turns. Key question: why forever rather than a single turn? Common bug: if blocks outside forever so the disc turns once only. Differentiation: support pairs place left arrow first and test; extension can tweak turn degrees for faster spin.
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
Model hide, forever wait random, create clone on Sprite1, then the when-I-start-as-a-clone hat with go to random, point towards wheel, show. Ask: why hide the original? Common bug: code on the wrong sprite or missing the clone hat so nothing appears. Circulate as they run the green flag.
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.