Scratch Clicker Tutorial: Cake Collector & Auto-Baker

Scratch Clicker Tutorial: Cake Collector & Auto-Baker
ok-scratch
Build a Scratch clicker game where cakes multiply with each click. Add click upgrades and an auto baker, balance rising costs, and add clone-based star effects.

So, what are we building in Scratch?

The project this tutorial is based on

clicker-game

clicker-game

by ok-scratch
Play it first Play it first
Here is the project we are working from. Both the click upgrade and the auto baker get seriously addictive — every purchase jacks the price up by 1.5x or 1.6x, and it just keeps climbing. It's not a flat price tag; a single formula, round(cost × multiplier), is enough to create that natural push-and-pull of "do I buy now or wait?" — the exact hook that makes idle games so addictive. Let's see how a game mechanic like that gets built from just one number.

What you'll build

  • Build a system where clicking makes cakes increase
  • Implement click upgrade and auto baker upgrades
  • Show a clear effect when the player reaches 1,000 cakes

#1Stage: Setting up the game

ok-scratch ok-scratch
From this step, we'll start building "Cake Clicker." First, over on the Stage, we'll handle the signal to start the game and the resetting of the numbers.

Eventswhen greenflag clicked kicks things off when the green flag is clicked. This is the starting point for everything.

We switch the backdrop to "Party" with Looksswitch backdrop to ( ) to give it a shop-like vibe.

After that, Variablesset ( ) to ( ) sets "★Cakes" to 0 and "★Click Power" to 1. The trick is to wipe the numbers back to a clean slate every time the game starts.

#2Cake: Placing the cake

ok-scratch ok-scratch
Now that the Stage is ready, next we'll put the star of the show—the cake—on the screen.

Start with Eventswhen greenflag clicked, then switch to the "Cake-a" costume with Looksswitch costume to ( ). It's the plain, uneaten cake—this is the default look.

Place it near the center of the screen at (0, 30) with Motiongo to x: ( ) y: ( ). The size is a big, bold 150.

We deliberately gave it a large stance so it's easy to click. Since it's the star, it earns the right to stand out.

#3Cake: Showing the cake

ok-scratch ok-scratch
Let's get the cake we placed into a state where it shows up properly.

Looksclear graphic effects resets any effects left over from the last run. On top of that, Looksgo to ( ) layer brings it all the way to the front.

Then Looksshow displays it. The order of clearing effects before showing it quietly matters—skip it and leftover transparency from before can stick around.

#4Cake: Click to add more

ok-scratch ok-scratch
This is the heart of the clicker. We'll build the main flow: click the cake and the count goes up.

Eventswhen this sprite clicked catches the click, and Variableschange ( ) by ( ) increases "★Cakes" by the amount of "★Click Power." How much a single click adds is held in a variable.

The moment it goes up, Soundstart sound ( ) plays a coin sound and Eventsbroadcast ( ) fires off the "Star Effect" signal.

The sound and the stars together create that "I clicked it!" feedback. That satisfying feel is the lifeblood of a clicker.

#5Cake: Click pop animation

ok-scratch ok-scratch
We'll add that pop animation where the cake springs a little the instant you click it.

First shrink the size down to 132, then repeat 6 times with Controlrepeat ( ), using Lookschange size by ( ) to grow it back little by little. It finishes by landing exactly back at 150.

Shrink it small, then gradually grow it back—this motion is what creates the feel of pressing it. It's only a few frames, but having it versus not makes a world of difference.

#6Stage: Setting up the prices

ok-scratch ok-scratch
Now that the cake itself is done, let's hop back to the Stage and line up the rest of the numbers.

Variablesset ( ) to ( ) resets "★Auto Bakers" to 0. This is the starting value, so it begins at 0.

Next, set "★Upgrade Cost" to 10 and "★Auto Baker Cost" to 50.

The 10 and 50 we set here become the starting prices when you go shopping later. Finally, Variablesshow variable ( ) puts "★Cakes" on the screen so the player can see it.

#7Stage: Showing the remaining numbers

ok-scratch ok-scratch
Continuing from before, now it's time to put the remaining monitors on the screen too.

Variablesshow variable ( ) shows "★Click Power" and "★Auto Bakers." Now you can tell your current upgrade level at a glance.

When the numbers are visible, the player can think, "Which one should I upgrade next?" It's subtle, but it's an important part that supports a clicker's strategy.

#8Upgrade Button: Placing the upgrade button

ok-scratch ok-scratch
Now that the numbers are sorted, next we'll build the "upgrade button" that powers you up using cakes.

Start with Eventswhen greenflag clicked, then set its look to "Button1" with Looksswitch costume to ( ).

Place it at the bottom-left of the screen (-150, -130) with Motiongo to x: ( ) y: ( ). The size is 80, kept more modest than the cake.

The button is a supporting player, so we balance it to stand out less than the star cake. This lead-and-support relationship is subtle, but it really helps the screen stay easy to read.

#9Upgrade Button: Keep showing the price

ok-scratch ok-scratch
We'll have the upgrade button show its current price all the time.

After showing it with Looksshow, keep a loop running forever with Controlforever, and the Lookssay ( ) inside keeps announcing the price.

The text it shows is built by joining "Upgrade" and "★Upgrade Cost" with Operatorsjoin ( ) ( ). The price changes every time you buy, so we rebuild it every frame to keep it up to date.

#10Upgrade Button: Checking if you can buy

ok-scratch ok-scratch
We'll build the part where the button decides "can I buy this right now or not?"

Using Controlif ( ) thenelse, we split the behavior into two based on a condition. The condition combines Operatorsnot ( ) and Operators( ) < ( ) to express "★Cakes is not less than the price"—meaning "you have enough."

Using "not less than" to mean "greater than or equal to" is a neat little trick. Scratch has no "≥" block, so we flip "less than" around to build the same meaning.

#11Upgrade Button: Showing affordability visually

ok-scratch ok-scratch
Let's fill in that check and convey visually whether you can buy it.

When you have enough, Looksset ( ) effect to ( ) sets the "ghost" effect to 0, making it crisp and opaque. When you don't, the same effect goes to 50, making it half-transparent. Ghost 50 instantly conveys a "can't press this" feel, doesn't it?

Normally you'd handle a button's enabled/disabled state by preparing two costumes and switching between them. But this project pulls it off just by changing the ghost effect's number. Since you don't add extra costumes, it's easier to fix later too.

#12Upgrade Button: Buying the upgrade

ok-scratch ok-scratch
Finally, the code for when you press the upgrade button. You pay cakes to raise your click power.

Eventswhen this sprite clicked catches the click, and Controlif ( ) then checks "do you have enough?" one more time. Even if it looks half-transparent, whether you can actually buy is confirmed for real right here.

If the condition is met, Variableschange ( ) by ( ) reduces "★Cakes" by the price. Then it raises "★Click Power" by 1.

It's a simple trade: pay and get stronger. As these moves stack up, the weight of a single click keeps growing.

#13Upgrade Button: Raising the price

ok-scratch ok-scratch
After a purchase, we raise the price so the next one costs more.

Variablesset ( ) to ( ) writes "★Upgrade Cost" back as the current price × 1.5. The key is rounding it to a whole number with Operatorsround ( ). Finally, Soundstart sound ( ) plays a purchase sound and we're done.

ok-scratch ok-scratch
Normally, we tend to keep an item's price fixed. But this project multiplies the price by 1.5 every time you buy. You could call this technique the very heart of a clicker game. Repeatedly multiplying by 1.5 makes the price climb a steeper and steeper curve—the so-called exponential growth. That's what makes you agonize over "when do I buy the next one?" If the price were fixed, you'd buy everything right away and get bored. It's precisely because of that steep curve that a balance you can keep playing forever is born.

#14Auto Baker Button: Placing the auto button

ok-scratch ok-scratch
Now that the upgrade button is done, this time we'll build the "Auto Baker" button. It's the entry point to a system that grows your cakes even while you leave it alone.

The flow is almost the same as the upgrade button. Start with Eventswhen greenflag clicked, then set its look to "Button2-a" with Looksswitch costume to ( ).

Place it at the bottom-right of the screen (150, -130) with Motiongo to x: ( ) y: ( ), size 80.

We line it up symmetrically with the upgrade button on the left to keep the UI consistent. When two identical shapes sit side by side, the controls become predictable and less confusing.

#15Auto Baker Button: Keep showing the price

ok-scratch ok-scratch
We'll have the auto button show its current price all the time too.

Show it with Looksshow, then inside a Controlforever loop, use Operatorsjoin ( ) ( ) to join "Auto Baker" and "★Auto Baker Cost" and keep announcing it.

What it's doing is exactly the same as the upgrade button. Being able to reuse the same mechanism on a different button is the strength of variables and loops.

#16Auto Baker Button: Checking if you can buy

ok-scratch ok-scratch
We'll have the auto button decide whether you can buy it too.

Split the behavior with Controlif ( ) thenelse, and use Operatorsnot ( ) and Operators( ) < ( ) to check "is ★Cakes greater than or equal to the price?" It's exactly the same idea as the upgrade button.

The only change is that what you compare against is now "★Auto Baker Cost." A check pattern you build once can be reused all over like this.

#17Auto Baker Button: Showing affordability visually

ok-scratch ok-scratch
Let's fill in the check so the auto button conveys affordability visually too.

When you have enough, Looksset ( ) effect to ( ) sets the "ghost" effect to 0; when you don't, it goes to 50. Same as the upgrade button—the strategy of showing on/off with the ghost effect.

Keeping the same look across both buttons means the player won't get confused. Once they learn "half-transparent = can't buy yet," it applies to either button.

#18Auto Baker Button: Buying an auto baker

ok-scratch ok-scratch
Let's build the code for when you press the auto button.

Eventswhen this sprite clicked catches the click, and Controlif ( ) then does a final check on whether you have enough. If the condition is met, Variableschange ( ) by ( ) reduces "★Cakes" by the price and raises "★Auto Bakers" by 1.

Each additional auto baker increases the automatic production we'll build later by that much.

A single purchase is like an investment that keeps paying off. If the click upgrade is "working out," this feels like buying "passive income."

#19Auto Baker Button: Raising the price

ok-scratch ok-scratch
This one raises its price after a purchase too.

Variablesset ( ) to ( ) sets "★Auto Baker Cost" to the current price × 1.6, and Operatorsround ( ) rounds it to a whole number. Whereas the upgrade button was ×1.5, the auto baker is set to a slightly steeper ×1.6.

Because the auto baker, which grows cakes automatically, is more powerful, its price climbs a bit more sharply. This dial of the multiplier is the knob that decides the game's balance.

#20Stage: Growing cakes automatically

ok-scratch ok-scratch
Now that the buttons are all set, next we'll head back to the Stage and build the auto baker's core. This is the part where the autos you bought actually produce cakes.

Start with Eventswhen greenflag clicked, and put a 1-second wait with Controlwait ( ) seconds inside a Controlforever. The code below runs once every one of those seconds.

Only when "★Auto Bakers" is greater than 0, Controlif ( ) then lets Variableschange ( ) by ( ) add that many cakes. Once per second, it grows by the number of autos—that's what automatic production really is.

The more autos you add, the bigger the per-second gain, so early investment slowly pays off later on. Cakes grow even when you leave it alone—that's the joy of a clicker.

#21Star Particle: Keeping the star hidden

ok-scratch ok-scratch
Now that automatic production is built, from here comes the final touch: the star effect that scatters with every click. Let's start by prepping the star sprite.

As soon as it starts with Eventswhen greenflag clicked, immediately hide it with Lookshide. The strategy is to keep the star's original out of sight and only show the clones we'll make later.

Hide the original and only move the copies—that's the basic form of clone effects. If the original stays visible, an extra star gets left sitting alone on the screen.

#22Star Particle: Creating star clones

ok-scratch ok-scratch
Let's build the part that spawns stars at the moment of a click.

Eventswhen I receive ( ) receives the "Star Effect" signal—the one that flies over when you click the cake. On receiving it, Controlcreate clone of ( ) makes one copy of itself.

This signal flies over every time you click, so rapid-fire clicking makes more and more stars. Combining signals with clones makes it easy to write effects that "mass-produce something in response to an event."

#23Star Particle: The star's initial setup

ok-scratch ok-scratch
We'll decide what each newborn clone looks like and where it appears.

Controlwhen I start as a clone is the cue for a clone's birth. Looksswitch costume to ( ) sets its look to "Star," and Motiongo to x: ( ) y: ( ) sets where it appears.

The clever bit is using Operatorspick random ( ) to ( ) for these coordinates. By making x a random number from -70 to 70 and y from 40 to 110, the stars scatter to a slightly different spot each time. So even rapid clicking doesn't pile them up in the same place, and it looks lively.

#24Star Particle: The star floats up

ok-scratch ok-scratch
We'll add the motion where the cloned star softly floats up and fades away.

First, Looksset ( ) effect to ( ) resets the "ghost" effect to 0 to make it visible. From there, repeat 10 times with Controlrepeat ( ): Motionchange y by ( ) nudges it upward while shrinking its size and adding 10 to the "ghost" effect each time. It's a motion that gets smaller and fainter as it rises.

ok-scratch ok-scratch
A single star's motion is simple, but the clever part is doing it with clones. If you just animate one original sprite, you can only have one star on screen at a time. With clones, though, as many stars as you clicked all dance at once in different places and at different moments. For "particle" effects like sparks or confetti, this approach is the standard. The knack for that floaty feel is changing the position, size, and ghost effect a little bit all at the same time. Move it all in one go and it looks choppy, but split it into 10 steps and it looks smooth.

#25Star Particle: Removing the star

ok-scratch ok-scratch
We'll properly clean up the star once it's done dancing.

Controldelete this clone has the clone delete itself once its motion is finished. This makes the star that's done its job disappear from the screen.

Cleaning up clones is unglamorous but hugely important. Scratch has a limit of only 300 clones at once, and if you leave them around without deleting, you hit the cap fast and no new stars appear.

#26Stage: Clear check

ok-scratch ok-scratch
Now that the effects are in place, next comes the clear check at last. When you've gathered plenty of cakes, we celebrate.

Start with Eventswhen greenflag clicked, and use Controlwait until ( ) to wait patiently until "★Cakes" becomes greater than 999. It won't move past this point until the condition is met.

Once achieved, Looksswitch backdrop to ( ) switches the backdrop to "Rays" and Soundstart sound ( ) plays a fanfare. The backdrop and sound change completely—we're going for that "I did it!" feeling in this moment.

#27Stage: Stopping after the clear

ok-scratch ok-scratch
We'll send the clear signal to everyone and wrap up the game.

Eventsbroadcast ( ) fires off the "Game Clear" signal. The cake, which receives this signal, will handle the clear effect afterward.

After that, Controlwait ( ) seconds leaves just 2.5 seconds of afterglow, then Controlstop stops everything. This order of showing the effect before stopping works well—it ends more satisfyingly than stopping abruptly.

#28Cake: The cake's clear effect

ok-scratch ok-scratch
This is the finishing step where the cake receives that "Game Clear" signal from earlier.

When Eventswhen I receive ( ) catches the signal, Looksswitch costume to ( ) changes its look to "Cake-b." It's like it turns into a cake that's ready to eat.

Finally, Lookssay ( ) for ( ) seconds has it say "Clear! 1000 cakes reached!" for 2 seconds, and it's happily complete. It turned out to be a project that layers the fun of collecting cakes with the satisfaction of reaching a goal.

Wrap-up

You should now feel how a simple click-the-cake action, combined with just variables and conditionals, creates that genuine "growth" feeling. The design where prices double up over and over is a technique you can reuse in any other clicker or idle game. Combine it with clone-based effects like the star burst, and try arranging your own custom clicker game.

Thank you for reading! Thank you for reading!
Bookmark and share this article, if you like.