How to create an Undertale game on Scratch – a lesson for children

How to create an Undertale game on Scratch – a lesson for children

Getting a beginner into programming is quite easy: you need to take a simple visual language and find a detailed lesson. This is what we offer and want to tell you how to write Undertale on Scratch.

“Undertale” is a computer role-playing game that captivates children and teenagers thanks to the plot: the player’s task is to get out of a virtual dungeon. You have to endure a series of battles with hostile characters: they can be punished or spared. The ending depends on the player’s choice, which makes even multiple playthroughs interesting.

Let’s make an Undertale clone in the Scratch language together, with the help of the visual code environment of the same name.

The lesson was prepared by the programming school for children Pixel. We offer a simple and consistent instruction: let’s start with the basics and move on to more complex issues to understand step by step how to create your own game from scratch.

Making the game “Undertale” in the environment “Scratch”: a tutorial for beginners

First we will need to go to official website of the program and log in to your account or create a new account. It’s free, and you can work with environment tools online.

If the first step is taken, let’s start creating our own clone of the game “Undertale”.

1. We create the first location and add objects to it

Undertale is first and foremost an adventure game, so we have a lot of locations to do. Let’s start with the main one and create its main parts. Let’s:

  1. Let’s create a basic background. To do this, select the fill and set the color to black.

  2. Let’s make improvised purple ruins, like in the original game.

  3. Let’s draw the road using a darker purple color with a stroke.

What should come out is shown in the screenshot.

Now we need to remove the lines inside the road. Let’s take a rectangle of the desired color and turn off the stroke.

And we also need a river and a bridge. You can add them using rectangles: blue and brown. Horizontal stripes of a darker color will help us make the bridge realistic. It should come out as shown in the screenshot.

2. We create additional locations

We need to make two more backgrounds. They need to be shown in the screenshots.

So we prepared three locations. Additional background is required: we will move to the corresponding location if we meet a monster. We will make and program it soon, but first we will do other things.

3. We draw a new background for interaction with the monster

Let’s repeat the partially familiar steps:

  1. Fill the workspace with black.

  2. Let’s create a transparent rectangle with a white outline, place it in the lower part of the screen.

  3. Let’s make a zone with green frames and cells, place it on top. This sphere is for a monster.

It should come out as shown in the screenshot.

An important aspect: the cells must be finished completely.

4. Let’s start programming the RPG in the “Scratch” language

First, let’s create the main character. If you go by the plot of Undertale, then you need a child. Basic steps:

  1. Let’s go to the sprite library.

  2. We choose the necessary option. Let it be Avery’s character.

  3. We reduce the standard size in the corresponding tab and set the value to 40.

We continue to code and use the following commands:

  1. When the flag is clicked, surrender.

  2. Set HP to 5.

  3. Go to the first background.

  4. Go to coordinates -154 and -134, that is, to the beginning of the track.

  5. Always repeat.

The iteration loop will contain four conditions. Here they are:

  1. Up arrow pressed, change Y to 10.

  2. Right arrow pressed, change X to 10.

  3. Down arrow pressed, change Y to -10.

  4. Left arrow pressed, change X to -10.

This is what the block code should look like:

4.1. We create an imitation of steps

We chose Avery in the wrong way: ready-made costumes are provided for this character. The block “change suit to suit a” must be inserted into the created cycle. Next, you need to set commands for suits b, c and d. Pauses of 0.5 seconds are required between them.

This is what our code will look like:

It is necessary to take a new block out of the general loop and insert it into another one with a repetition condition.

Now let’s go back to the first command and create a condition like this: if it concerns the edge, go to the new location of the second background and coordinates -207 and -2.

4.2. We draw and program a detail for teleportation to the battle map

Here is what detail you can draw:

The code with the “when flag is clicked, hide” command is required. The drawn part should appear after hitting the second location, so we go to the program for the character and finally insert the message “key”.

But the conditional teleporter itself also needs a visual code. Here’s what you need to write: when the message is received, appear and go to one of the branches of the road with coordinates 137 and 112.

Let’s go to the script for Avery and create a condition: if it concerns the key, send the “game” message.

Next, you need to program the following: when you receive the “game” message, you need to hide. A command must be created for a key and a character.

4.3. We create a new sprite – a pixel heart

Before making the game “Undertale” in the “Scratch” environment, you need to clarify the following point: during battles, the main character becomes a heart. We need to create it. We select red squares and draw them.

You can’t do without a code. The following command is required: when the flag is pressed, hide, when the “game” message is received – appear and go to coordinates 4 and -97, turn on the fourth background.

We will set the size of the heart only at the level of forty units.

Now you need to select the infinite loop and insert it inside the motion condition. We will control our hearts not with arrows, but with beech trees.

Here are the commands needed:

  1. If the W key is pressed, change Y to 10.

  2. If you press the D key, change the X to 10.

Similarly, we give S and A, write: change Y to -10 and X to the same amount, respectively.

Temporarily place the background change inside the loop, and then remove it.

4.4. We make a monster in the form of a frog

Now it’s time to create the monster. Let’s start with drawing:

  1. Let’s take the white oval and use the change of points to remove the lower part.

  2. Let’s add two circles – improvised eyes.

  3. Let’s draw the body, changing the upper part using dots.

  4. Let’s make two ovals in the form of legs with additional oval elements – paws – at the ends.

  5. Let’s add an arc to the house of the abdomen.

This is what should come out:

Now we need a rubber band. Let’s make it thin and set the size to ten: this will help to carefully draw the mouth and eyes for the improvised monster.

The next step is to select and combine parts of the frog’s body. Let’s set its size to 50, drag the monster into the field with previously created green cells.

It remains to write the block code. Here are the commands needed:

  1. When the flag is pressed, hide.

  2. When I get the message game, give up and go to coordinates 1 and 66.

  3. Repeat the loop always, change Y to 1 and wait 0.2 seconds, change Y to -1 and wait another 0.2 seconds.

Thanks to the code, our frog will be able to move.

4.5. We draw and program the projectile

The projectile in our project is a “dangerous enemy”: it must be avoided. Let’s create a suitable sprite.

For drawing you will need a white circle, and for the code – the command “when the flag is pressed, hide”. In addition, we will write: when I receive the message “game”, appear and go to coordinates 39 and 78. Other important blocks:

  1. Repeat the cycle 10 times.

  2. Create your own clone and go to random coordinates. A random number generator will choose them. Ranges: X -2-253, Y – from -173 to -63.

Next, we prescribe an additional command: swim for one second to the heart. And we also write the following: when I start as a clone, when touching the first sprite, change HP to -1 and delete the clone, otherwise just delete.

Now let’s change the time allotted for the movement of the projectile. Instead of one second, set the value to 0.8.

5. We make the final touches

We change the heart rate: instead of ten, we set the value to only five.

Now let’s go to the code written for the character and add a condition to the end. It looks like this: if HP = 0, we lost. The game stops.

Let’s remember how many backgrounds there were to understand that there is one unused. It will come in handy in case of a successful impromptu battle with the monster. Let’s add the command for the projectile with the message “background 3” as shown on the chest.

We will also change the script of the character and write the following: when I receive the message “background 3”, appear and go to coordinates -207 and -2. In addition, you need to set the switching of the conditional location accordingly.

All other elements should disappear. It can be programmed with a single command: when I get the message “background 3”, hide.

Let’s go back to the code for the heart and get the “switch background 4” construct out of the loop so we can go back to the third location.

Yes, our instruction has come to an end. We hope that everything worked out!

If there are errors, we advise you to take a look educational video: it will help to understand how to make an RPG in the Scratch environment using the example of Undertale

And we want to ask you to tell us whether it was possible to write the visual code according to the instructions. If not, what were the difficulties? Share your thoughts, leave comments: this will help us make more informative and simple lessons for children.

The material was prepared by the Pixel programming school. We teach IT-enthusiastic kids to write code, create 3D models, script websites and more. If you want to learn more about Scratch programming, come to our courses for the younger ones and for seniors students

Related posts