Game development for kids is an essential element to teach kids coding at UnicMinds. In this post, we’ll see the steps required to create a two player Maze Runner game in Scratch. The simple goal of this game is that the players help the cat sprites to reach the goal – a delicious apple!.
Overview of the steps required to completely code the Two Player Maze Runner game in Scratch
Step 1: Create the maze sprite and adjust its properties
Step 2: Create the cat sprite and adjust its properties
Step 3: Write the code to move the cat in all directions
Step 4: Write the code to check if the cat is touching the walls of the maze
Step 5: Create the apple sprite and adjust its properties
Step 6: Add the code to check if the cat touches the apple
Step 7: Create another cat sprite and another apple for the second player
Step 8: Add the code to the new cat sprite and apple sprite for the second player
Step 1: Create the maze sprite and adjust its properties
Go to the link https://coding-coacher-41.webself.net/file/si1741863/download/maze5-fi27009675.png and download the maze image. Select the upload Sprite option on choosing a sprite. Select the image of the maze downloaded from the link above. Change the size to 100 to adjust the maze on the screen. Drag the maze sprite and place appropriately on the screen so that it’s visible.
Step 2: Create the cat sprite and adjust its properties
Change the size of the cat to 15 so that it can easily move inside the maze.
Step 3: Make the cat sprite move around
Add the following code to move the cat using up, down, left and right keys.
Step 4: Check if the cat is touching the walls of the maze
Add the following code to check if the cat is touching the walls of the maze.
The code above checks if the cat has touched the wall of the maze while moving up.
The code above checks if the cat has touched the wall of the maze while moving down.
The code above checks if the cat has touched the wall of the maze while moving right.
The code above checks if the cat has touched the wall of the maze while moving left.
Complete code to check if the cat touches the wall while moving in any direction
Step 5: Create the apple sprite and adjust its properties
Click on choose a sprite option and click on the apple. Once the apple gets added on the screen, change the size of the apple to 15. Change the x and y coordinates to 91 and 169 respectively to place the apple at the top of the maze.
Step 6: Add the code to check if the cat touches the apple
On touching the apple, a cheer sound will be played and the cat will say “Yippee!”.The cat will come back to its original position.
Complete code after adding the above code
Step 7: Create another cat sprite and apple for the second player
Duplicate the cat sprite and change its costume to blue as shown below
Duplicate the apple sprite and change its costume to green as shown below
Step 8: Add the code to the new cat and apple sprite for the second player
Add the code below for the blue cat sprite to be controlled by w , a, s and d keys.
Please contact us or book a free trial class to learn more about how to build games and learn programming at UnicMinds.
Hope this two player game was useful, thank you.
For similar reading, refer AI for Kids, Minecraft for Kids, What are Events in Scratch Programming, and Coding Courses for Kids .