How to make a Doors game on Scratch
Let's make a “Doors” game in Scratch and create our own virtual room, draw a scary character and program it. Simple and clear instructions with screenshots will help: it breaks down the main steps and shows what needs to be done and how.
We are in Pixel We often use the Scratch environment in block programming courses for preschoolers and primary schoolchildren, as well as for older children. We believe that this approach is a plus: the marked tool teaches you to create games, animation and interactive stories through the use of bright blocks reminiscent of commands in text languages. This leads to the formation of a number of important skills and to an understanding of the basics of programming: algorithms in the form of simple and complex sequences, as well as relationships and other principles.
Today we propose to make Doors in Scratch – an interesting project where the player’s task is to explore a limited virtual world in search of new fragments of the general map. If you are unlucky, you will face a terrible monster.
Interesting? Then let's get started. But first, let's note that we won't create map fragments: we'll just program the doors and the monster.
How to make Dors in Scratch: step-by-step instructions
First, we will present a text guide with visual screenshots, and at the end we will publish a video: it will help you perform a self-test and correct errors if they occur.
We suggest you get started.
Step #1: Create the basics of the game map
We suggest starting with a basic background: let's draw a fragment of the corridor. To make it look realistic, we will give preference to a three-dimensional image. Let us immediately note that in the 3D world the following rule applies: the closer the objects are to the player, the larger they are. An additional principle follows from this: space should expand as it approaches us.
Let's start creating. Required actions:
Select the Line tool.
We create the floor. You need to start and end at the same point. The goal is to close the space: without this it will not be possible to fill our virtual floor.
We draw the walls. Let's start with the left, move to the right and finish on the far one, that is, the back. Remember the first rule: objects closer to us should appear larger than those further away.
Let's assume the light is on the ceiling. Therefore, you need to paint the floor and walls accordingly: the first will be light, the second a little darker (left and right). Let's make the far wall the darkest.
Step No. 2: making doors
We will make the doors in the same way as before. You will need:
Take the line.
Draw a rectangle so that it is parallel to the left wall. It must be placed accordingly.
Duplicate the suit. The first will indicate a closed door, the second – an open one.
Color new costumes. We suggest making the closed door red and adding a handle in the form of a yellow circle.
Use turquoise or blue to paint the inside of the room. This will indicate that the door is open.
Paint the open part of the door red and add a handle. Let's name the sprite “Door 1”.
Now we need to work on the second door. Let's place it on the far central wall. We repeat the steps already completed, but for painting we use green color. Don't forget the pen.
Next, on the second suit you need to complete the open part and make it, as before, turquoise or blue.
Let's use the name “Door 2”. It remains to add a third similar element. The steps are the same as for the first door, but we suggest using purple to indicate the outer surface. Let's name the sprite “Door 3”.
Step No. 3: write the Doors program in Scratch
We suggest starting the creation of block code for today's project by working on the first door. Actions:
We use “When the flag is pressed” and “Go to coordinates”, as in the screenshot.
Add a command to change the active suit to the first one.
We write a second command of this type: the sprite is pressed, change the costume to the second one and send the message “Door 1”.
We create similar scripts for the second and third doors. You will need to change the coordinates and messages as shown in the screenshots.
Shall we check the program? If everything is done correctly, our mini-application in the form of the Doors project in Scratch will work at the simplest level: doors will open when you click on them.
Step No. 4: create a monster and program it
Let's make a monster. Let it be black and made up of lines: you can draw the sprite chaotically and add red eyes to it for intimidation. It is enough to repeat the approximate drawing, as in the screenshot.
Now let's go to the script and write the command: when the checkbox is clicked, hide. You will need to create a new variable with the door number and set the initial value to 0.
A repetition cycle is needed. Additionally, you will need to set the variable to change randomly in the range from 1 to 3. This will help introduce an element of unpredictability into the project: after starting the game Doors in Scratch, the monster will be hiding behind an unknown door.
Next, you will need to create a new command of this type: when the message “Door 1” is received, go to the front layer and check if the monster is hiding in the corresponding room.
If we selected “Door 1”, we need to program the command: show up, set the suit size to 100% and go to -152 and -24.
Now we program the following:
After moving to new coordinates, wait 1 second.
We swim to the center at 0 and 0, increase by 50%.
So, let's say, if we start the game and number 1 is selected, the monster hides behind the corresponding door and when it opens, it appears and begins to move towards the central part. In today's project, this event means losing and ending the game.
We proceed in the same way with the remaining doors. The commands for them are clearly shown in the screenshots below.
Finally, let's make a sign announcing the loss and write YOU LOST in red text.
Let's move the sign a little so that it is easy to read, and also write the following commands.
The last step is to hide the variable: this is necessary to add an element of surprise to the Doors project. It’s impossible to predict which door the monster is hiding behind.
Educational video about creating the game “Dors” in Scratch
As promised, we offer a video tutorial. You can view it at:
So, we figured out how to make a Dors game in Scratch. We hope everything worked out. If yes, you can start playing.
If you have any questions or would like to see more lessons, be sure to leave comments.
Material prepared by Pixel School. Our children and teenagers learn Scratch, Lua, Python, C#, JavaScript and also create games, program websites, make 3D models and computer graphics. If a child 6-8 years old or older is interested in Scratch, be sure to take a peek: we will teach him to confidently use the environment and complete even complex projects. This will lay the foundation for further programming training.