The Week Junior - Science + Nature

archery Create an game

Hit the target with this shooting challenge.

-

What you will need:

 A computer

 Scratch

 Lightning-quick

reactions

How does it work?

This project uses a free, online coding language called Scratch. By creating programs using Scratch, you can improve your problem solving skills. This activity teaches you about animation and colours.

Crosshair script

1

First, on your computer go to rpf.io/archeryon to open up the starter project in Scratch.

2

Click on the arrow sprite (icon) on the right side of the screen. It is a crosshair (a plus sign in a circle).

3

Now, build the script above. A script is a stack of coding blocks that makes a set of instructio­ns. Drag the colourcode­d blocks from the list on the left-hand side of the screen. Snap them together in the coding area in the middle.

4

Begin with the “green flag” hat block. Then, select the “broadcast” block. Change the option by clicking the dropdown menu and selecting “new message”. Type “new arrow” in the box.

5

Complete the rest of the script, altering the inserts where necessary. Check each line carefully.

6

After you have popped in the “set size” block, click on the green flag to run the script. You should see your arrow get bigger and move to the bottom-left of the stage.

7

Finish the script and test your game again. Now, the arrow should move randomly around the stage.

Arrow script

1

To shoot arrows, add the script (left) to the coding area in the middle of the screen. Remember to check each line of code carefully.

2

Begin with a hat block as usual. Then, drag and drop the “stop” block and select “other scripts in spite” from the drop-down menu.

3

The next sequence of coding blocks assigns a score to each of the colours on the archery target. You will need to match the exact target colours in each “touching colour” coding block. The easiest way to do this is with the eyedropper tool. Click on the colour in the coding block and select the symbol. Then move your mouse over to the archery target on the stage. Click to select the correct colour.

4

You can also add a cheer sound and for a pop-up score for each arrow.

5

Finish with a “broadcast” block and you are ready to test out your game.

The Raspberry Pi Foundation is a Uk-based educationa­l charity working to put the power of computing and digital making into the hands of people all over the world. Discover more step-by-step coding projects at rpf.io/ scienceand­nature

 ?? ??
 ?? ??
 ?? ?? Arrow sprite
Arrow sprite
 ?? ??
 ?? ??

Newspapers in English

Newspapers from United Kingdom