lesson 4 pac-man-style game - chulmleigh ict...

12
Introduction to Scratch Programming v1.4 (Second Ed) 4 – Pac-Man-Style Game Introduction to Scratch Programming (2 nd Edition) Page 1 of 12 © ZigZag Education, 2013 Lesson 4 – Pac-Man-Style Game What you will learn: how to delete, draw, animate and resize a sprite how to move a sprite using keyboard control how to design a maze on the stage how to stop the sprite moving over the maze how to get rewards to randomly appear and disappear how to set up scoring how to chase the Pac-Man with an automated sprite Ideas for developing the game further: Introduce more rewards. Set a time limit or a target score. Introduce further moving sprites that work against the player. Make it into a two-player game. Further sprites could be added to block/unblock sections of the maze. This could make the game change as it is played. There could be different levels with the background changing after a time. Contents Exercise 1 – Creating the Maze ...................................................................................................................... 2 Exercise 2 – Creating the Packman ............................................................................................................... 4 Exercise 3 – Creating Variables ..................................................................................................................... 8 Exercise 4 – Setting up the Points Score ....................................................................................................... 9 Exercise 5 – The Chaser ................................................................................................................................ 11

Upload: others

Post on 10-Jul-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Introduction to Scratch Programming v1.4 (Second Ed) 4 – Pac-Man-Style Game

Introduction to Scratch Programming (2nd Edition) Page 1 of 12 © ZigZag Education, 2013

Lesson 4 – Pac-Man-Style Game

What you will learn:

how to delete, draw, animate and resize a sprite

how to move a sprite using keyboard control

how to design a maze on the stage

how to stop the sprite moving over the maze

how to get rewards to randomly appear and disappear

how to set up scoring

how to chase the Pac-Man with an automated sprite

Ideas for developing the game further:

Introduce more rewards.

Set a time limit or a target score.

Introduce further moving sprites that work against the player.

Make it into a two-player game.

Further sprites could be added to block/unblock sections of the maze. This could make the game change as it is played.

There could be different levels with the background changing after a time.

Contents

Exercise 1 – Creating the Maze ...................................................................................................................... 2

Exercise 2 – Creating the Packman ............................................................................................................... 4

Exercise 3 – Creating Variables ..................................................................................................................... 8

Exercise 4 – Setting up the Points Score ....................................................................................................... 9

Exercise 5 – The Chaser ................................................................................................................................ 11

Introduction to Scratch Programming v1.4 (Second Ed) 4 – Pac-Man-Style Game

Introduction to Scratch Programming (2nd Edition) Page 2 of 12 © ZigZag Education, 2013

Exercise 1 – Creating the Maze

1. Select the scissor tool and delete the cat sprite.

2. Click the stage icon.

Introduction to Scratch Programming v1.4 (Second Ed) 4 – Pac-Man-Style Game

Introduction to Scratch Programming (2nd Edition) Page 3 of 12 © ZigZag Education, 2013

3. Select the Backgrounds tab and click Edit.

4. Use the Fill tool and set the whole background to red.

5. Set the pen colour to black and draw a simple maze on the background. 6. Click OK.

Introduction to Scratch Programming v1.4 (Second Ed) 4 – Pac-Man-Style Game

Introduction to Scratch Programming (2nd Edition) Page 4 of 12 © ZigZag Education, 2013

Exercise 2 – Creating the Packman

1. Click the Paint new sprite button.

2. Working in Paint Editor, draw an orange circle.

Introduction to Scratch Programming v1.4 (Second Ed) 4 – Pac-Man-Style Game

Introduction to Scratch Programming (2nd Edition) Page 5 of 12 © ZigZag Education, 2013

3. Working on the Costumes tab, click Copy.

4. Select the copied costume and click Edit.

5. Select the transparency colour from the colour chart.

Introduction to Scratch Programming v1.4 (Second Ed) 4 – Pac-Man-Style Game

Introduction to Scratch Programming (2nd Edition) Page 6 of 12 © ZigZag Education, 2013

6. Paint the open mouth of the Packman. Click OK.

7. Rename the sprite to Packman and costumes to Packman1 and Packman2.

8. Click the shrink sprite tool and resize the Packman so that it will fit in every part of the maze.

Introduction to Scratch Programming v1.4 (Second Ed) 4 – Pac-Man-Style Game

Introduction to Scratch Programming (2nd Edition) Page 7 of 12 © ZigZag Education, 2013

9. Create the scripts for the Packman as shown.

Animates the Packman Remember to set the wait times to 0.1 seconds.

These commands allow the player to drive the Packman using the arrow keys.

This command makes the Packman bounce off the maze. Use the pipette tool to set to the same colour as the maze.

Introduction to Scratch Programming v1.4 (Second Ed) 4 – Pac-Man-Style Game

Introduction to Scratch Programming (2nd Edition) Page 8 of 12 © ZigZag Education, 2013

Exercise 3 – Creating Variables

1. Click the Variables instruction set and click Make a variable. 2. Make a variable called Score.

3. Amend the animation script so that it sets the position of the sprite to top right-hand corner of the

game and resets the score to zero at the beginning of each game.

Introduction to Scratch Programming v1.4 (Second Ed) 4 – Pac-Man-Style Game

Introduction to Scratch Programming (2nd Edition) Page 9 of 12 © ZigZag Education, 2013

Exercise 4 – Setting up the Points Score

1. Click Choose new sprite from file.

2. Browse for the Things folder.

3. Select the banana. Click OK.

Introduction to Scratch Programming v1.4 (Second Ed) 4 – Pac-Man-Style Game

Introduction to Scratch Programming (2nd Edition) Page 10 of 12 © ZigZag Education, 2013

4. With the banana sprite highlighted, create the script as shown.

This command sets the start position.

This command shows the banana.

This command makes something happen if the banana touches the Pac-Man.

This command changes score.

This command hides the banana.

This command shows the banana.

This command waits a

random amount of time.

This command chooses a random position.

Introduction to Scratch Programming v1.4 (Second Ed) 4 – Pac-Man-Style Game

Introduction to Scratch Programming (2nd Edition) Page 11 of 12 © ZigZag Education, 2013

Exercise 5 – The Chaser

1. Create a new sprite that will chase the Pac-Man and end the game if it catches it!

2. Create the chaser script as shown.

This command sets the starting position.

This command sets the starting direction.

This command chases the Pac-Man.

This command makes the sprite bounce off the maze.

This command makes the sprite bounce off the banana.

This command ends the game if the sprite touches the Pac-Man.

This command makes the sprite bounce off the edge.

Introduction to Scratch Programming v1.4 (Second Ed) 4 – Pac-Man-Style Game

Introduction to Scratch Programming (2nd Edition) Page 12 of 12 © ZigZag Education, 2013

The game should look like this when it starts: