INTRODUCTION TO PROGRAMMING USING SCRATCH FOR PROGRAMMING AND CONTROL 9 Creating a Packman-Style Maze Game INCLUDED IN THIS EXERCISE: Delete, draw, animate and resize a sprite Move a sprite using keyboard control Design a maze on the stage Stop the sprite moving over the maze Get rewards to randomly appear and disappear Setting up scoring Chase the Packman with an automated sprite WAYS OF 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 9 | Creating a Packman-Style Maze Game Select the scissor tool and delete the cat sprite. Click the stage icon. Introduction to Scratch Programming Page 2 of 12 © ZigZag Education 2011 9 | Creating a Packman-Style Maze Game CREATING THE MAZE Select the Backgrounds tab and click Edit. Use the Fill tool and set the whole background to red. Introduction to Scratch Programming Page 3 of 12 © ZigZag Education 2011 9 | Creating a Packman-Style Maze Game Set the pen colour to black and draw a simple maze on the background. Click OK. CREATING THE PACKMAN SPRITE Click the Paint New Sprite button. Introduction to Scratch Programming Page 4 of 12 © ZigZag Education 2011 9 | Creating a Packman-Style Maze Game Draw an orange circle. Working on the Costumes tab click Copy. Select the copied costume and click Edit. Introduction to Scratch Programming Page 5 of 12 © ZigZag Education 2011 9 | Creating a Packman-Style Maze Game Select the transparency colour from the colour chart. Paint the open mouth of the Packman. Click OK. Rename the sprite to Packman and the costumes to Packman1 and Packman2. Introduction to Scratch Programming Page 6 of 12 © ZigZag Education 2011 9 | Creating a Packman-Style Maze Game Click the shrink sprite tool and resize the Packman so that it will fit in every part of the maze. Introduction to Scratch Programming Page 7 of 12 © ZigZag Education 2011 9 | Creating a Packman-Style Maze Game CREATING THE PACKMAN SCRIPTS Create the scripts for the Packman as shown. Animates the Packman remember to set the wait times to 0.1 seconds. Allows the player to drive the Packman using the arrow keys Makes the Packman bounce off the maze – use the pipette tool to set to the same colour as the maze Introduction to Scratch Programming Page 8 of 12 © ZigZag Education 2011 9 | Creating a Packman-Style Maze Game Click the Variables instruction set and click Make a variable. Name the variable Score as shown below. Amend the animation script as follows. Sets the position of sprite to top right-hand corner of game Resets the score to zero at beginning of each game Introduction to Scratch Programming Page 9 of 12 © ZigZag Education 2011 9 | Creating a Packman-Style Maze Game SETTING UP A REWARD Click Choose new sprite from file. Browse for the Things folder. Select the Banana. Click OK. Introduction to Scratch Programming Page 10 of 12 © ZigZag Education 2011 9 | Creating a Packman-Style Maze Game With the banana sprite highlighted, create the script as shown. Sets the start position Makes something happen when the banana touches the Packman Shows the banana Changes score Hides the banana Waits a random amount of time Chooses a random position Shows the banana CREATING THE CHASER SPRITE Create a new sprite that will chase the Packman and end the game if it catches it! Introduction to Scratch Programming Page 11 of 12 © ZigZag Education 2011 9 | Creating a Packman-Style Maze Game CREATING THE CHASER SCRIPT Create the chaser script as shown below. Sets starting position Sets starting direction Chases the Packman Bounces off maze walls Bounces off banana Ends game if it touches the Packman Bounces off edge The game should look like this when it starts: Introduction to Scratch Programming Page 12 of 12 © ZigZag Education 2011
© Copyright 2026 Paperzz