Coding Book 2 February 21
Cat and Mouse (A Chasing Game)
Make Music
Contents 3 Scratch Interface Guide 4 Coding Blocks 5 Costumes Sounds 6 Sprite Pane 7 Cat and Mouse 8 Overview and Step 1 9 Steps 2 and 3 10 Step 4 11 Step 5 12 Steps 6 and 7 13 Step 8 14 Steps 9 and 10
15 17 19 21 23 25 27 29 31 33 35 37 39
The Big Picture
1
Make Music Play a Drum Make a Rhythm Animate a Drum Make a Melody Play a Chord Surprise Song Beatbox Sounds Record Sounds Play a Song Combine the Projects What do these programs do? Index and Glossary
Attitude Listen carefully to instructions
Look carefully at examples
Sherlock Show curiosity:
Give helpful help Pointing and talking
Hmmm! I wonder what this does?
Taking over and doing it
Memory
Learn from Mistakes
Work hard to remember these skills.
Mistakes are the proof you are trying.
Edgar Ferjennery
Miss Take 2
Scratch Interface Guide Explore each part of the screen to find out what each one does.
Code Blocks: Colour-coded that snap together to create a program. Costumes: Create a new sprite or redesign an existing one. Sounds: Add sounds to your program. Code Area: This is where you write your instructions. Drag the blocks onto the script area and join them together to create a set of instructions for your sprites and stage. Sprites Pane: This is where you organise your sprites. Sprites are either characters that move around the stage or a backdrop that decorates the stage. Stage: This is where the action happens! The sprites move around the backdrops following the program you have written using the blocks from the block palette to the code area. 3
Coding blocks: Drag these colour-coded blocks which link together like Lego bricks onto the Script area to make things happen. Look at page 5 for more information about the different types of blocks.
4
Costumes: Explore the tools to create new sprites or redesign existing ones.
Sounds: Explore the tools to add sounds to your program.
5
Sprite Pane
Choose a Sprite
Choose a Backdrop
Sprites: Any character or object. You can program them to move, make sounds, change appearance and much more.
Backdrop: You can paint the backdrop, choose a picture or add a photo.
Stage Sprite: You can add blocks to program the stage.
6
Cat and Mouse
This is a two player game. Start the game by pressing the space bar. Player 1 controls the mouse with the mouse. (As you move the mouse pointer around the screen, the mouse sprite follows it). Player 2 moves the cat with the arrow keys. The mouse gets 1 point for touching the small red cheeses and 10 points for touching the big yellow cheese. The cat gets 10 points for touching the mouse. The game lasts for 30 seconds or you can stop it by pressing the s key. Take turns to control the cat and the mouse. Who can get the highest score? Have fun! 7
10 Steps Step 1: Play the game with a partner. Step 2: Paint a backdrop for the stage Step 3: Choose 2 sprites for your game Step 4: Control the mouse sprite with the mouse Step 5: Control the cat sprite with the arrow keys Step 6: Compare the two sprites Step 7: Set up the cat scoring system Step 8: Set up the mouse scoring system Step 9: Add a timer to stop the game Step 10: Evaluate
Step 1: Play the game Play with a partner. Take it in turns to be the cat and the mouse. What works well? What needs to be improved? How would you like to make your version unique?
8
Step 2: Paint a backdrop for the stage 1. Imagine the blobs of colour are lumps of cheese for the mouse to eat. It is important that the colours are clear. 2. Click on the stage sprite. 3. Find the 3 tabs above the Block Palette. 4. Click on the Backdrop tab. 5. Paint a backdrop using 2 colours. Make it unique but don’t make it too complicated.
Step 3: Choose 2 sprites for your game
Choose a sprite 1. Choose a sprite that will chase. 2. Choose a sprite that will run away. 3. Delete sprites you don’t need. (Click on the bin)
9
Step 4. Control the mouse sprite with the mouse
1. Click on the sprite that you are going to use the mouse to control. 2. Drag these blocks onto the Script Area.
3. Press the space key and test whether your sprite follows the mouse pointer. 4. Experiment with the number of steps the sprite moves. Which number is just right?
Can you explain what the blocks mean?
10
Step 5: Control the cat sprite with the arrow keys
1. Click on the sprite you are going to control with the keyboard. 2. Drag these blocks onto the Script Area.
3. Test it. When you press the arrow keys, does the sprite move in the right direction? 4. Experiment with the number of steps the sprite moves. Which number is just right? Can you explain what these blocks mean?
11
Step 6: Compare the two sprites Test your how well your two sprites move around the stage. Have you made it fair or is it too easy for one of the sprites?
Step 7: Set up the cat scoring system 1. Click on the Cat sprite in the sprites pane.
2. Click on the orange variables block in the Block Palette. 3. Click Make a Variable.
4. Type cat in the variable name box. 5. Click OK.
6. Drag these blocks onto the Script Area to give the cat points for touching the mouse: Can you explain what these blocks mean?
12
Step 8: Set up the mouse scoring system 1. Click on the Mouse sprite.
2. Click on the orange data block in the Block Palette. 3. Click Make a Variable.
4. Type mouse in the variable name box. 5. Click OK.
6. Drag these blocks onto the Script Area to give the mouse points for touching the small cheeses:
7. Drag these blocks onto the Script Area to give the mouse points for touching the large cheese:
13
Step 9: Add a timer to stop the game 1. Click on the stage sprite. 2. Click on the orange data block in the Block Palette. 3. Click Make a Variable. 4. Type timer in the variable name box. 5. Click OK. 6. Drag these blocks onto the Script Area to create a timer to stop the game after 30 seconds:
Step 10: Evaluate What are you pleased about? What have you learnt? Which step was the trickiest? How did you make your game unique? What would you like to improve? 14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
Combine the projects
35
Now that you have experimented with these 9 algorithms, try combining at least two of them to create a final performance. How many of these skills can you include? In what ways can you make your project unique? Can you create an orchestra? This image might give you some ideas.
36
What do these programs do? Match the numbers with the letters. 1)
2)
3)
4)
5)
6)
A) Make a sprite spin on the spot when you click it. B) Move around the screen and bounce off the edges. C) Move up the screen when the up arrow key is pressed. D) Say, “Hello!” grow bigger and then say, “HELLO!” E) Press d to play the drums. Press q to make them quieter. Press l to make them louder. F) Move around the edges of a square.
37
Glossary
Index Arrow keys, 11 Block palette, 4, 5 Cat and mouse, 7-14 Chord, 25-26 Costumes, 4, 6 Drum, 17-18, 21-22 Interface guide, 3 Keyboard, 11 Melody, 23-24 Mouse, 10
Rhythm, 19-20 Score, 12, 13 Script area, 4 Song, 27-28, 33-34 Sounds, 4, 6 Sprites, 4, 9 Sprites pane, 4 Stage, 4, 9 Timer, 14
38
Can you write a program? Can you predict what a program will do? Can you debug a program? Can you create something unique? Do you have a positive attitude towards solving problems? Do you give helpful help? Do you learn from mistakes? Can you remember the skills you learnt last time?