How to Make a Maze on Scratch

by NoDripDev in Living > Video Games

709 Views, 1 Favorites, 0 Comments

How to Make a Maze on Scratch

2965DED0-6743-415E-ABA6-E03CB02D4E95.png

You will be making a maze, using only simple coding blocks and a little bit of your time. Scratch mazes are fun to make and are even more fun to share with your friends.

Supplies

1D602F98-BCCA-41DF-8B4C-4E49FF9DBE6D.jpeg

All you need is the internet and scratch!

Size Your Cat

276980C1-3AF9-4FA4-AABB-B1C98262A575.jpeg
BA5A7FA0-E3A2-49BE-ACDB-4281AA8DC817.png

When you first make the project, go to the right bar under the game and make the size of the cat to 50. You can also add a code like: When flag clicked Set size to 50%

Movement of the Cat

92704012-A719-4A75-BADF-C2F015DF30B6.png

This is going to be the movement of the cat’s x-axis. When you start, you want to add a when flag clicked, forever, if left arrow key clicked then, change x by -4. Do the same thing for the right arrow except instead of -4 make it 4.

Movement of the Cat Part 2

D056488E-CC72-4089-AE49-CCAC7ACC6A13.png

For the y-axis, you want to make it so instead of change x by 4 make it change y by 4. You want the if to be in a forever script, then if up arrow key clicked, change y by 4. Do the same thing for down arrow except instead of 4 make it -4.

Make the Cat Be Centered

80B856C9-6C98-4200-AB2D-A4D10D80D1AC.png

On this code, move your cat wherever the start of the maze will be. Pull over the when flag clicked block and put the go to x =_ and y=_ block under the flag block so whenever you start you will go to that position.

Make the Maze

35C09CD2-C136-43B7-AE91-FDC1A93427BD.png

The title explains itself. Make another sprite and make the maze. Line up the lines with the scratch cat and then you are done with your maze.

Reset If Touching Maze

8EF2F652-525C-44C5-8BDE-DA351DA03AEB.png

You might find that as you are moving the character, it can go through the maze. To fix this, make a block of code. When flag clicked, forever, if touching sprite 2, then go the starting position (the block of code that goes, go to x=_ and y=_) ***MAKE SURE THE CODE IS ON THE CAT***

FINAL STEP

313720E9-C293-4E78-BB2B-17E37F09AFB0.png

Add another sprite. Move it to the end of your maze. Make a code on the cat that goes like, when flag clicked, forever, if touching sprite three (the end sprite) say You Win)