How to make a clicker on Scratch from scratch – a lesson for children

Making a clicker game in Scratch is easy. We want to prove and offer clear step-by-step instructions with screenshots: even a beginner can handle it. Let us immediately note that for the successful completion of the project, an understanding of Scratch is desirable: if you have experience working in the program or in Scratch Junior, everything will work out.

We are in an online school Pixel We use Scratch to teach block programming to children 6–12 years old and implement two programs: the first is intended for preschoolers and primary schoolchildren, and the second is aimed at more experienced children. But that’s not what we’re talking about today: we want to offer a mini-lesson that will help you figure out how to make a clicker in Scratch.

Let us be interested and emphasize that the current character will be represented by a hamster, as in Hamster Combat – a game in the corresponding genre that has managed to win the hearts of millions of children, teenagers and even adults.

We suggest skipping the digressions and getting to the point: let's start creating a conditional imitation of Hamster Kombat in Scratch. First, we will present detailed text instructions with screenshots, and at the end we will publish an informative video: watching it will help you perform a self-test or delve into unclear moments and eliminate errors.

How to create a clicker in Scratch 3.0: step-by-step instructions

The following are the basic steps: they are described in detail and accompanied by screenshots for a better understanding of what Scratch tools you will need to use and what you need to do in general to complete the project in the form of a full-fledged clicker in the Scratch environment.

Step #1: go to the platform and start creating the game

By default, the base object in every new empty project in Scratch is a cat sprite.

Our clicker today, as noted, will be with a character from Hamster Combat. The main idea of ​​the project is to have three levels, so we will need a similar number of costumes. We suggest starting with their creation.

You will need to do the following:

  1. Remove the cat sprite.

  2. Loading the hamster costumes.

Note: it is necessary that the costumes are not separate sprites. In today's project they are intended for one acting character. It is important that it and the loaded suits are controlled by a single program.

So, the costumes for the project are loaded and ready to be used in the clicker in Scratch.

Now select the background. You will need:

  1. Click on the corresponding button in the lower right.

  2. Select the appropriate option. We suggest focusing on an imitation of a stage or dance floor: it seems that this is the most successful background. If you decide to choose another option, don’t worry, because this will not change the essence of the project being carried out.

Step #2: Create Additional Sprites

Our clicker in Scratch requires the creation of the first additional sprite – bonus points. They will be shown and displayed every time you click on the hamster.

First, you will need to use tools designed for drawing and working with the text content of graphic elements. Steps:

  1. Select a brush. After this, a field for creating costumes will open.

  2. Click on the “Text” tool and write +1.

The presented action is necessary so that each click on the hamster leads to an addition to the score, that is, to an increase by one unit.

Now let's prepare new costumes for the created sprite. These are +2 and +4. The principle is simple: we create the basis for increasing points in the form of triggering a bonus condition and successively doubling conditional rewards.

Be sure to name costumes and other objects accordingly to avoid confusion in the future. You can build on the screenshots and make similar names, which will be a plus. In this case, there will be no need to get confused when implementing further actions.

Now let's move on to creating an additional object – a button. We will click on it with the mouse when we need to purchase a bonus.

Thus, the presented button is intended for purchasing a conditional option in the form of an increase in the bonus. The bottom line is this: when you click, the cost per click will increase. But not for free: first you will have to give away part of the accumulated points.

You can add the required button as follows:

  1. Click on the cat on the bottom right.

  2. Select the object as in the screenshot.

  3. We write the text. It should be noted that the click is multiplied by 2 at the current price, say, set at 10 conventional units.

We've sorted out the sprites, so let's get down to the fun part – programming. You will use a number of simple and complex block designs to write scripts for the character and other objects.

Step No. 3: write code using block structures

Programming the clicker will be simple: if Scratch is not yet familiar enough, we hasten to note that the environment for writing code uses bright block structures. Their use is intuitive and rarely difficult.

We suggest starting with the character. Steps:

  1. Let's move on to the “Events” block.

  2. We use “When the checkbox is clicked.”

This construction is intended to launch the program and must necessarily open and precede the block code for any project.

Now let's create a couple of variables. They are useful for storing important information about:

Let's make the appropriate variables and set the initial values. In the case of a bonus it is 1, and in the case of a score it is 0.

Next steps:

  1. Let's go to the control unit.

  2. Add a “Repeat Always” cycle. It is necessary and necessary for the game to run continuously within one launch.

  3. Add the “If” condition. It needs to set an introductory requirement of this type: clicking the mouse on a sprite leads to the addition of points.

  4. We go to the operators and find “And”. This element will be required to add the two parts of the indicated condition.

  5. We find in the sensors a mouse click and a character’s touch.

Now, if the specified complex condition is met, the account should increase by a multiplier that is relevant for the current, that is, active bonus. First it is +1, then +2 and +4.

Let's make the clicker more complicated and eliminate the possibility of adding a bonus an unlimited number of times in a short period of time. This will require creating a delay. The design “Wait 0.1 seconds” is suitable. You can see how everything should look in the following screenshots.

We suggest programming the hamster's jumps: this will help visualize the clicks on it. The solution will make the game more interactive and fun.

Required steps:

  1. Go to the “Motion” tab.

  2. Change Y to 10 before the wait block.

  3. We enter the value -10 into the coordinate.

Next, let's program the launch of the bonus, that is, its demonstration on the screen. We proceed like this:

  1. We use “Message from events”.

  2. Click on “Send message”, set the click and display the relevant information.

Let's program the first sprite. You need to script the following: receiving a command in the form of a click leads to the creation of a clone. It will need to be programmed separately: it is necessary to set the appearance at the point of pressing, as well as the subsequent upward movement.

Required actions:

  1. We use the control unit.

  2. Let's script the creation of a clone and start in the appropriate quality.

  3. Let's move on to the movements, find the block for moving to a random position and change the contents to the mouse pointer.

  4. Additionally, we set the movement to X for one second. Let's set the value to +200.

Let's work with Y in a similar way. The addition operation will come in handy.

Click on the green flag to check the program. Did the pluses fly up? Great! But there is a noticeable error: the icons appear behind the character. The fix is ​​simple: let's go to the Appearance tab and add Go to Front Layer. Additionally, you will need to use the “Delete Clone” command: it will help prevent the plus signs from freezing on the screen. As a result, the corresponding game objects will freely leave the active area of ​​the clicker.

Step No. 4: finalizing the clicker program on Scratch

We have created various objects and parts of the program, but it is far from ideal: the clicker requires improvement. First of all, we suggest creating a dependency. The “Bonus” variable must be associated with the flying picture. We are talking about the following: if we have a bonus unit, the +1 image appears, etc.

Let's do the following:

  1. Let's move on to “Events”.

  2. Let’s add “When the checkbox is clicked” and make a repetition script like “If, then”.

  3. Let's create a condition: if the bonus is 1, the suit changes to +1.

Now you need to duplicate the “If” block and make minor changes. Using the example of a hamster sprite in the screenshot below, the required block code is shown.

It is important to program the clicker so that with a bonus of +1 the hamster is without clothes, with +4 – with glasses, etc. Enough:

  1. Take the already written program from the first sprite.

  2. Drag it into the hamster code window.

  3. Change costumes as in the screenshot.

Now at the very beginning of the game we see a naked hamster: in order to dress him up and make him cool, you will need to earn enough points and buy the necessary bonus several times.

Step No. 5: finalizing the button

All that remains is to work with the button: in today’s project it is responsible for increasing the bonus.

We need a script that will check whether we clicked the button with the mouse and whether there are enough points to increase the bonus. It is also necessary to script the debiting of earned funds in the form of points and more.

Actions:

  1. We go to the operators, use two blocks and connect them as shown in the screenshot.

  2. We add sensors inside and write “Touches the mouse pointer.”

Additionally, you will need to add parts of the code, as in the screenshot below: they will be responsible for verification.

Fulfillment of the presented conditions will lead to progress and a change in the value of the bonus, as well as the value on the game balance. The latter should be reduced by the price of the purchased bonus if the corresponding action is performed.

Here's what you need to do:

  1. Select “Set values ​​from the variable panel”.

  2. We use the operators “Multiplication” and “Subtraction”.

Let's script the restoration of the button: we'll make it so that it is impossible to activate the bonus several times in a row. The essence of the program addition is as follows: the new part will hide the item intended for purchase. You will need:

  1. Use “Wait 1 second” from the control panel.

  2. Apply Show and Hide.

It remains to limit the number of available bonuses to three conditional levels. An “If” construct is required. Condition: bonus is 4, the buy button is hidden.

So, we created our own clicker in Scratch from scratch. I suggest you test it. Everything should work as we programmed: you can see that at startup the bonus is equal to one, and the score is zero. You can start saving points and leveling up your hamster!

If everything is done correctly, then when clicking we will receive an increase in the balance. We hope everything works.

Video tutorial on creating a clicker on Scratch for beginners

If the text instructions seem complicated or the program does not work, be sure to watch the training video. It is available:

There is no difference: choose any convenient platform and start watching a video tutorial on creating a clicker in Scratch. It will be interesting!

It should be noted that in the training video, the Pixel school teacher not only spoke in detail about the implementation of the hamster clicker project from the acclaimed game Hamster Combat, but also showed what and how exactly to do. Even a child without experience in block programming can cope with the lesson.

In conclusion, we would like to ask you to devote one minute to us and share your experience: were you able to cope with the project? If not, be sure to tell us what caused the difficulties.

The material was prepared by the Pixel programming school. If you are interested in block coding and want to master Scratch, we invite you to course for children 6–9 and on online classes for children from 8 to 12 years old.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *