Scratch Program Maze

Scratch
  1. Scratch Maze Background
  2. Invent With Scratch Maze
  3. Scratch Programme

I am going to make program small Scratch maze. You will be able to move the cat around by using the arrow keys on your keyboard. You will not be able to go through the maze walls even if you tried. The objective of the game is to get to the very end of the maze. So, lets go into how to create this program step by step. Go ahead and start up the scratch editor by clicking on create.

The fist thing you will do is download this maze image. Simply right-click on it, and save it on your computer. You could draw it yourself by painting a new sprite. Use this maze image.

Back in the Scratch editor you can upload this image from your computer by clicking on the upload sprite icon from the file. Move the cat out of the way, and adjust the maze imagine to be in the center of the stage. The cat is way too big for this image. You will have to grab the shrink tool and then click several times on the cat to shrink it down. It should look like this. We want the Scratch maze program to move the cat around whenever the player presses on the arrow keys on the keyboard.

Free online course in Scratch: Many more games in the free Scratch Programming. 1 Maze Game Lesson Plan Introduction: We will be programming a maze game in Scratch. The main goal of this game is to program your sprite to be able to navigate.

So, in the brown events category grab ”when green flag clicked” block. Then from the yellow Controls category grab the forever block. This will run through the code that is inside its mouth forever.

Scratch Maze Background

We want it to check if a arrow key is being held down. Grab the if-then block and from the light blue sensing category grab the key pressed block, and fit it inside the condition socket for that if block. In the drop-down menu choose left arrow key. To actually move the cat sprite, go to the dark blue motion category and grab the ”change x by” block.

And since we are changing the x coordinate to go left, we need to have this be a negative number. We could go back and add all those block for other arrow directions, but I am going to make a small shortcut for this Scratch maze. Right click on the ”if-then” block and select duplicate. That will give us a nice duplicate set of all the blocks already. And all you have to do now is change it to ”right arrow” and since we are moving the right direction, change the x by 4, instead of -4. Duplicate the ”if-then” block all over again, and change the last to ”if-then” block to control the up arrow and the down arrow. Also, delete the ”change x by” blocks to ”change them to ”change y by” blocks.

They are responsible for the y coordinate movement. For the up arrow direction change it by 4, and for the down direction change it by -4. Test the maze game often. Test the program out.

You should be able to move the cat to all direction, but we don’t the cat to be able to move around right through the walls. Also, the cat looks for stiff just gliding around.

We are going to add walking animation too. Click on the red stop button to stop the program. Lets also have the cat to always start at the beginning of the maze when the program first starts up. Move the cat at the start of the maze, and then go to the dark blue Motion category. Add one ”go to x y” block right before the ”forever” loop. The coordinates for this block will be already set.

Now to animate the Scratch maze cat, the sprite comes with two different costumes. Click on the costumes tab in the center to see them. When you switch between these two costumes to get a walking animation. There are programming blocks that can switch costumes.

They will be under the purple Looks category. Grab the ”next costume” block and put one of this block inside each ”if-then” block.

Now when you click on the green flag, the cat has a nice walking animation. Now we want to make a program that will not let the cat pass right through the walls. In a way we will do that is by checking if the cat is touching the black color of the walls. And if so, we will cancel out whatever movement it makes that allows it to pass through.

Inside the first ”if-then” block add a new control ”if-then” block from the Control section. This will check if the cat sprite is touching the black maze wall.

Scratch

Invent With Scratch Maze

In the sensing category, grab the ”touching color” block and insert it. We want to set it that – if the cat is touching the black color. To do so, click on the color box and then click on the black of the maze walls, right one the stage. To undo the leftward motion that cat makes, because the user pressed the left arrow key, add one ”change x by” block.

Except this block will change x by 4. So, when the user presses the left arrow, the cat moves to the left, but if the cat ends up touching the black maze wall, because of moving to the left, we will have it counteract that by just moving back four pixels to the right. Do this for each direction. Awesome, you have created a Scratch maze!

Scratch Programme

. Original Author: Richard Wiktorowicz, Moorefield Girls High. Education Level: Preschool and Kindergarten, Elementary School, Middle School, High School, College and University, Professional Development, Other.

Content Types: Activity, Handout. Curricular Areas: Computer Science, Engineering, Language Arts, Mathematics, Music, Science, Social Studies, Teacher Education, Technology, Visual Arts, Other. Keywords:, These worksheets were created by Richard Wiktorowicz. Each worksheet starts off by giving students step-by-step instructions on how to do something in Scratch, and then asks them to apply the skills to create new things. The worksheets seem to be designed for students who have some knowledge of Scratch.