Slime Clicker – Game Design

Introduction

Okay so my first ever game, so to make it easy and to help me get to grips with unity we are going to start with a cookie clicker since you can’t really get much simpler than that. However I didn’t want to just make cookie clicker as that would just be boring, however I also didn’t want to focus too much on the art so wanted something simple, leading me to a game I haven’t played in ages. Slime Rancher, known for being a cute slime farming game, it has a simple theme and I just kinda like slimes in general because of how flexible they can be in so many situations purely because of their nature.

However I won’t cover the art on this blog as I already have in the art section, I separated them because one that would make these way too long, and two because it makes it neater

Game Link

Just in case you want to see what this is all about:

https://budbot5002.itch.io/slime-clicker

Required

Okay so to make a clicker game you need a button to click, that button then needs to increase the amount, seems simple enough. But no you also need to update a score of how many they have on screen and allow them to use these for upgrades, either increasing how much gained from clicks or just passive income. Which yeah is a lot more complicated than the former, so let’s get the basic skeleton covered first

Button Clicking

Alright so first let’s make the button increase the slime amount every time its clicked, to do this I just got a button, put my graphic on it (details in the art blog) then made a script called scr_clicking which does:

This, which literally just makes public values I can update later on upgrades, then counterNumber is the used version that is added to when counter is the converted used to show the current slimes, but we will get to that later.

The main part of this is because of clicked which we can apply to an action on the button (being clicked) we can call it and add to the counterNumberthe amountPerClick, allowing for us to already tick the first box.

You can also see in the update we update a text to show the counter number, allowing us to cover that box too, killing two birds with one stone, but then obviously we need to link this to the text somehow, which is through just linking it to the one we want on unity

To show what I mean by applying the action I will show you the state of the button in unity aswell

The part I am referring to is the On Click() part, here is where we can make it do something when it is clicked, such as run a subroutine such as Clicked which we will use later for the other needed buttons.

As you can also see we have set the appropriately named counter text to the counter so it will update that with our number so the player can see it in game

To cover the slime generation part, that is covered later but is basically how the slimes art generated from upgrades since they need to add to the counter number which is in the button

Upgrades

Click

Okay so now that we can press a button and increase a number, we need a way to spend these to get more of the stuff for less work as that is more satisfying pretty much. So to start with let’s upgrade the click and for this, since we are making slimes I called it alteration magic as it is used in most games to alter stuff, and so generate more slimes, basically altering your spell you’re using to clone them. For that I just made another button and made a new script:

Okay there is alot going on here so I’ll try my best to simplify it,  firstly we take Clicked as we need to increase that amount per click value, then we take the click power to tell the player what they are buying (basically get amount per click and add one). Current price is the current price of the upgrade so they know if they can buy it, this is calculated from base price which is displayed with the upgrade name.

These are then pretty much used to add to the price to make the economy of the game make sense, increase the amount per click and then update the text each time the upgrade is bought since the upgrades values need to change to the next upgrade.

However, how do we display all this? Well like we did for the counter but a bit more complicated, we can set a text box under the button(connected under it not just under it(drag it in the hierarchy and drop it on the button to get this)) and when the button has the mouse enter display the info, when it exits display the name. Incase you still don’t understand here is the button:

As you can see we have the script for buying and then the enter and exit events that do as I explained before, it pretty much just updates the text given if the mouse is over it or not. So now that we have the click upgrades, how about a passive upgrade?

Passive Upgrades

Mage Hand

Okay so to keep with the fantasy feel and since I was looking into DnD alot at the time I thought if us clicking the slime made more slimes, why not just make another hand to do it for you? Which is what the mage hand does, which I also took inspiration from the normal clicker hand from cookie clicker obviously. I did want to make them actually clicking the slime but at this point I was nowhere near that point so decided it was a lost cause

To make this we just get another button like the click upgrade, do the same with the text but we need another script that instead makes slimes, which results in:

This, which basically tracks if it is making slimes, if not it is made to true and increased, if true it makes slimes depending on the increaseAmount and waits for a second before turning off, basically making the slimes to be generated by the amount per second, which again is what most clickers do which is why I did it too.

Now that we can make them passively we need a way to increase the increaseAmount as when this is activated it will only make one per second, so we need to make a script that turns this on and is able to actually increase the amount that is passively made, which I made this for:

Okay so this might look pretty complicated but the bottom is the same text swap when entering and exit, then we have a few variables you will recognise, such as base price and upgrade info. However we also have nextSlimePerSec1, it was originally without the one but after debugging I had to seperate it from the other upgrade due to them both being public, so they would clash if I didn’t do this.

Okay so to start with we just set the upgrade to generate 1 and set the price to the base price, this will start when the button is actually pressed, so we don’t have to worry about it giving slimes on startup. Then we check if the player had enough slimes when clicked, if so we take the needed amount increase the auto increaseAmount by our nextSlimesPerSec, then we increase the amount by 1.5, I could have used powerOf to increase it more mathematically correct to what other clicker games do but I thought this increase was enough. Then all we need to do is put this on the button, like so:

Just like before we have the exit and enter events but we have the new script in here as well which yes is more complicated but it basically just uses the same math, just increasing the increaseAmount in slimeGeneration instead of the click power.

Slimey Cauldron

So because most clickers tend to have multiple of these passives I made the cauldron which makes sense since slimes are just a magical liquid that became alive, and what makes magic liquids? Witches, what do witches use? Cauldrons, so it works out. It did also have a witch planned but due to time restraints and because it would just be yet another copy and paste I left it out, so you probably know what this will be now since yeah it is literally a copy and paste of the code from mage hand with a few adjustments since this is supposed to be the more expensive but better upgrade, leading to:

This literally just had a higher price and added two slimes per sec per upgrade instead of 1 because adding one would just be boring, so a better upgrade gives a better amount. Then we just need to put this on our cauldron button like so:

And yeah that is the upgrades completed

Conclusion

For a first project I think I did quite well, even if it is a clone I learned alot about the UI and even though I doubt I will make more clickers I am happy I learned this much and will be able to use it in future for stuff like menus and such, making it definitely not useless for the future

Leave a comment

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