 You've seen them around you know those scratch maze games and now you're wondering how do I make one well stick around because in this tutorial I'm gonna show you how to get started and make an easy one just for beginners in just a moment Hello world, it's surfing scratcher here teachers surfer program and lover of learning bringing you the goodness of learning through games on this channel We code scratch projects together via video tutorials So if you're new here consider subscribing at any point during the video check out the show notes and links in the description below I list out resources unplugged activities and PDFs that can help you along on your learning journey. All right Let's get stuck into it. Okay, so you've pressed that create button. It's taking you here the scratch project page Let's go ahead and give our project a name. Cool. Let's go ahead and delete the scratch cap We're gonna create our own sprite and it's gonna take the shape of a circle Now the reason for that is that the ancient Egyptians used to call the planet names Wanderers because they didn't know what they were in the sky They were like dancing around everywhere. So that's what our dude is gonna be doing in the maze It's gonna be your wanderer. So let's call it a wanderer wonder Let's put our wonder in the center of the stage zoom back out beautiful. Okay our wanderer needs some eyes I'm just gonna zoom back in and a little stroke. Let's get some more circles happening There's one eye. Let's copy it and two eyes. Cool. Now our wanderer is currently looking right So makes sense to name this costume right and duplicate and this one look left grab this eye come over there Might space them out a little bit more beautiful. Now we'll look on left Duplicate that this one. It's gonna look up and one more time. Hopefully know where this is going. It's right all the way down Beautiful right left up and down cool. So let's jump across into our code and hook this up Whenever you start a project you press the green flag. So let's go get that block from events When the green flag is pressed we need to forever do something So the idea is that when we're pressing the arrows, which I'm currently doing right now and nothing is happening We want our wanderer to look in that direction. So let's do that. Gonna get an if block Going to get a key press and we're gonna go for the right arrow change the look I'm gonna switch the costume to right make sense. Okay, let's duplicate that do the same thing but the left side All right, let's see how we're going. So there is right there is left going back and forth back and forth cool Holding it down. Looks like it's working duplicate. Oh, let's go up. I like up. Cool I'm gonna press the green flag and look I'm looking up now. So there's left. There's right and now it's up I'm pressing down not working because we need to put that piece of code in there. So duplicate once more Let's go down boom. Okay, and let's press that green flag Boom down up left and right. Yeah, okay. So this is cool, but Something wrong like our wonder is not moving. So let's work that out. Okay, so let's look at right and left first So what we need to do is we need to go and get some motion blocks Now we know that going across means moving along the x-axis So we're gonna be grabbing a motion block that is changing the x which is this one just here So we want to change a positive value that means we're gonna be going right So let's just grab that straight out of there and change the x by 10 So I'm gonna press down the right key now. Watch what happens. We okay. There goes our wanderer I'm trying to come back, but it's not happening. So what I need to do is I'm just gonna duplicate that and Instead of going positive 10 we're gonna go negative 10 So I'm gonna press the green flag and yes, our wonder is coming back So now our wonder I can go to and for the screen yee-ha, but it cannot go up or down Let's change that. We can no longer want the change x. We want the change y block So let's do that change y by 10 green flag and up it goes But it won't come back down and you know why that is Because we need to go subtract 10 yee-ha our wanderer is wandering around Open space floating in space. I don't know but let's like make things a little bit more difficult for our wanderer While we're at it, I'm just gonna reduce the size of our wanderer here to about 60 Okay, so let's go ahead and put in some levels and give the backdrop a color Cool now, let's go ahead and create some levels gonna get the rectangle tool I'm gonna get a nice black outline going on here. Let's make it about it's pretty cool And let's get some pretty gnarly colors happening. I like this pink. It's like one of my favorite pinks going around Okay, let's just draw a shape like this and let's pop it up here while we're at it Let's change that name to levels. All right, cool. Let's get our arrow tool and drag this around I like making this a little bit thinner Cure looking nice All right, so let's crack one there gonna copy that and paste it to there back into the center And there we go. All right, cool So we've got some levels now gonna press the green flag and our wanderer is still wandering around But look there is an issue just like going straight through our walls that we don't want it to be doing So we need to change that. Let's do that. So I've just jumped back into our wanderer sprite I'm going to zoom out a little bit here. I'm going to grab another green flag block And we're going to get another forever block. I'm going to get another statement So now we want to check for a color. So if our wanderer is touching the color Which color is that going to be? Well, let's go get it. It's our gnarly pink that we selected before So if our wanderer is touching that color, then we want it to go back to probably where it is right now So let's go like move it to a starting spot. So that's a pretty cool spot. We are going to take that position I'm going to go to it right there. Boom And uh, while we're at it like let's just go to that position when we start the game too Okay, press the green flag. Let's go around. Yeah, ha and oh there we go I hit the wall and going straight back to the start and you'll see that when I press the green flag again It goes back to the start. So that's looking pretty good The last thing that we want to do to our game is like we get to here and we need to end the game So we need to create a way for the game to end So let's go ahead and do that and jump back into the level sprite and rename this to one And I'm just going to draw another funky color funky green green funky Oh big Cool. So we're back in our wanderer code and let's just duplicate this statement And attach it beneath. Let's change the color to that gnarly green Boom and now we're not going to go there anymore. Let's just say I found you Okay, let's go back to the start Here we go wandering around. Oopsie doodle. There we go. I'm back to the start and boom I found you So there we go. That is the basics of a scratch maze game There's heaps more that we could do with this. We'll look at doing some other stuff in future videos All right, it's time for a scratchy question I really want to know what feature do you want to put into your maze game drop your reply in the comment section below And I might even make a video for it. Hey, thanks for checking out this tutorial Subscribe and like if you're new around here and have a scout of all my other content Which should be on the screen right now If you can't get enough then head on over to my patreon page link below Where you can join a membership tier and gain access to exclusive content But until then I'm off to go find a wave. I'll catch you in the next one