Scratch Game
Advanced
60 mins
245 points
What you need:

Attack of the Dots

In this project we create a game where you control a coloured disc and you must spin it to match the coloroured dots that are attacking!

1 - Remix the starter project

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/


2 - Make the disc spin

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:

whenclickedgotox0y0 place it in the centersetsizeto30% resize the wheel to 30%foreverifkeyleft arrowpressed?thenturn3degrees turn anti clockwiseifkeyright arrowpressed?thenturn3degrees turn clockwise

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


3 - Clone the ball

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':

whenclickedhideforeverwaitpickrandom4to8seconds wait a random number of secondscreatecloneofmyself create the clonewhenIstartasaclonegotorandom position start in a random positionpointtowardswheel point in the direction of the wheelshow


4 - Not too close!

We don't want the balls appearing too close to the wheel as it won't give us much time to react. So to prevent this add the following code to 'Sprite1' which detects where the ball is when it's cloned and deletes it if it's too close.

whenIstartasaclonegotorandom positionpointtowardswheelshow add new code under hereifdistancetowheel<100thendeletethisclone


5 - Make them move

Now that they're appearing randomly every few seconds we need to make them start moving towards the wheel. We've already used a block to point them at the wheel so now we just need to add this code to 'Sprite1':

whenIstartasaclonegotorandom positionpointtowardswheelshowifdistancetowheel<100thendeletethiscloneforevermove2steps add this code


Join our club 😃

To view the remaining 4 steps and access hundreds of other coding projects please login or create an account.

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