How to Make a Clicker Game in Scratch | Tutorial

– Hi, everyone. It's Zoë from the scratch team. Also known as Zinnea. Today, I wanted to show you how to make a clicker game in scratch. If you haven't played one before, a clicker game is a game where there's a certain item you can click on to get more points and then, there's other items that you can buy and they'll give you even more points. It sounds so simple, but they're really satisfying to play. And it's really fun as a game maker because you can decide what are all the objects that the player can unlock. So, yeah. By the end of this tutorial, you'll be able to make
your own game like this. Let's get started.

So first, let's pick the first object that you want the player
to be able to click on. You can just hover over it, choose a sprite, and click choose, and pick any object that
you want for your game. I will pick the apple. And let's start by making this sprite play a sound when you click it. You can go to the sound category and drag out a start sound, block and click on that to make the sprite play a sound. (sprite sound) And if I go to the events category and add a when this sprite clicked block on top. Now, whenever I click on the apple, it plays a sound.

Now, let's make it so that every time the player clicks on the apple, they get a point. To do this, we can make a variable. In scratch, a variable lets you keep track of a certain number in your project. So here, we can make a variable and call it points. And now, we can use this to keep track of how many points the player has scored. I'm also going to delete this my variable variable by right clicking on it or CTRL clicking on it and clicking delete.

So, to make the player get a point every time they click the apple, we can drag out this block, change points by one. This increases our points by one. And if you put this block under the, when this sprite clicked block, now whenever the sprite is clicked, (sprite sound) it plays a sound and the
points increase by one. And we would like the points to be zero when the project starts. So, you can drag out this block, set points to zero and then, put a when green flag clicked block on top. And now, every time you
click the green flag, the points start back at zero. Also, we can make the
click even more satisfying by making the sprite grow and shrink when you click on it. So, if you go to the looks category and drag out the set size block. So, if I try set size to 110%, it gets a bit bigger. Set size to 100, will set it back to its usual size.

And if I do set size to 110, wait for 0.05 seconds and then, set size to 100, it does a little animation where it froze and shrinks really quickly. So, if I attach this under the when this sprite clicked block, now every time I click on it, it does a little animation. You could also choose
your own sound to play when the sprite gets clicked. So, if you click on the sounds tab and then click on choose a sound, you can pick whatever sound you like. My favorite thing to do is, I'll choose the sound, boop bing bop and then, I'll click and select everything except this last piece. And then, click delete. And then, the only part that's left is this little sound (animation sound) which I love. So then, once you're done with your sound, you can click on the code tab and just click in this menu and choose it.

Now, let's add the next item in the clicker game. And let's make it so that with this item, you have to save up points and buy it. I'll show you how to do that. So, pick what you want
the next item to be. I'll pick the orange. And here's what we'll make the orange do. This is how purchasable items in clicker games work.

It will cost 10 points to be able to click on the orange. And then, when you click on it, you will start automatically getting one point every second. Then, you could click on the orange again and buy another. And now you're getting two new points every second. And this is where clicker games start to get really fun. Which is, you can eventually be getting thousands of points every second, automatically, which could enable you to buy even more expensive items.

So to start, let me show you how to
do that with the orange. So, we're going to need a new variable to keep track of how many automatic points the player is getting every second. So, let's click make a variable and I'll call it automatic points per second. Now, let's click on the costumes tab and click on the text tool and write down how much you want this item to cost. I will make the orange cost 10 points and let's also write down how many points per second it will give the player
once the player buys one. I'll make it give the player one automatic point per second. Let's go back to the code tab. So, if the player has less than 10 points, we want the orange to appear grayed out because they can't buy it yet.

Here's how you can do that. In the looks category, you can drag out a set color effect block, but instead of color effect, choose ghost effect. And if you set that to 60, that makes a sprite look transparent or faded. And then, this block, clear graphic effects, will make a sprite look normal. And let's drag out an if else block, we can say if the points are less than 10, set the ghost effect to 60, make it look faded out. Otherwise, clear graphic effects and make the sprite look normal. And if we put this inside a forever loop, now, the project will always be checking this if else block. So, it will always check does the player have less than 10 points? If the player has less than 10 points, it will make the orange look faded. Otherwise, it will make
the orange look bright. And we can put a when green flag clicked block on top so that, this code starts when the green flag is clicked. Now, so when the game starts, we only have zero points. And so, the orange looks faded.

And then, once we have 10 points, it looks bright. Like, we can buy it now. Now, let's drag out a when this sprite clicked block. In the game, what should happen when the player clicks on the orange? Well, let's drag out another if else block, because if the player
has less than 10 points, nothing should happen because they don't have enough points to buy the orange yet. So, we can actually just leave this part of the if else block blank. However, if the player
does have 10 points, then… Well, let's make it play a sound. We'll start with that. (animation sound) Okay. Okay, I don't have 10 points yet. I try to click on the orange, nothing happens, but now that I have 10 points, I can click on it and it makes a sound. And what else should happen when the player
successfully buys an orange? Well, it should take away 10 points from the player. So, let's change points by negative 10 because you see, we've got to spin, you have to make sure that the player actually spends the money. And the orange should start giving you an automatic point every second.

So, here's how you do that. Let's change automatic
points per second by one. You're increasing it by one. Okay, let's try it out. So, I get 10 points, I click on the orange and buy it. Okay, it decreased my points, I spent the money, and my automatic points
per second went up, this variable went up, but if I don't do anything, if I don't click, I'm not actually getting any automatic points per second. We have to add some code that will do that. Let's click on the apple to add this code because only one sprite
needs to be doing this. So, let's just make
the first sprite do it. Try this. If we say, when the green flag is clicked, forever wait one seconds and change points by one. What happens? Okay, this makes your score increase by one every second because it waits one second and then, adds one to your points.

Even if you're not clicking. But let's say I buy two oranges. Now, I should be getting
two points every second. And if I have three oranges, I should be getting three
points every second. So, we don't just want our points to increase by one every second. We want them to increase by whatever this variable is. So, instead of one here, you can just drag in the variable, automatic points per second, and put that here. And now, the project always adds whatever this number is to your points. So, if you've gotten
automatic points per second up to five, you'll get five points every second. And if you've gotten it up to a thousand, you'll get a thousand points every second. And when the game restarts, we want the automatic points per second to start at zero.

So, we can just add this block, set automatic points per second to zero under the when green flag clicked block. So, that's how you can
add automatic points to a clicker game. And now, if you just make more objects like the orange, you can have as many items as you want and you can make them as
expensive as you want. Let me show you how you
could add one more item. So, let's say for the next item I want a fruit salad. You just have to give
all the items this code. It's very similar to the oranges code, but let me show you where it's different. I want the fruit salad
to cost 80 points to buy. And I want it to give you plus seven points per second. So, in all of these places, I have to put in 80 because that's the cost
of the fruit salad. We want to check that the player has 80 points to be able to buy it. And then here, we want
to take 80 points away from the player because they paid for it.

And then here, because the orange is giving you plus seven to your
automatic points per second, there should be a seven here. Oh, and I also went to the costumes tab and wrote in the cost of
this item and the reward. So, that's all you need to do to be able to add as
many purchasable items as you want to your game. Anyway, that's what I
wanted to show you today. The link to this project is in the description below if you want to remix it. And yeah, I hope you have
fun making clicker games with your own items and your own themes.

I can't wait to play them. I will probably spend
too long playing them. I played so many clicker games when I was making this video. Yeah, I'll see you next time. And scratch on. (animation sound).

As found on YouTube

You May Also Like