How do I make upgrades for clicker game

Just started using Construct 2? Post your questions here

Post » Fri Dec 09, 2016 12:30 pm

So im making a clicker game and i want to add upgrades for my clicks. at the moment you get 1 point for clicking a sprite but i want it to be upgradable so when i buy the first upgrade i 2 points per click then 4 then 8 and so on.

Also i want to make an upgrade that gives points over time.

Thanks for help in advance!
B
2
Posts: 2
Reputation: 154

Post » Fri Dec 09, 2016 11:40 pm

Make the amount you get from clicking a variable, and change the variable when an upgrade is bought.
B
27
S
6
G
5
Posts: 18
Reputation: 3,967

Post » Sat Dec 10, 2016 2:53 am

Games are variable based. If the engine doesn't have a system expression for it then you need to add variables.
You can then change the variables with simple math using events. If you change a variable the events that have that variable will still work the same way.

You would want to create a Global Variable called "ClickPoints" and have it set to 1.
If you have a score then you want to create a Global Variable called "Score".

If the goal of the game is to destroy objects by clicking, then when that object is destroyed you want to put in an event that will go something like this.

When the object is destroyed
Add "ClickPoints" to "Score"

Every time an object is destroyed it will increase the "Score" variable by how much "ClickPoints" is set to.
1 will add 1 to Score.
2 will add 2 to Score.
This allows you to give the player an upgrade by only changing a variable. It will only change if the conditions you gave it are met.

You can change the value of "ClickPoints" by using events.
Add 1 to "ClickPoints"
or
Set "ClickPoints" to 2

You said an upgrade that gives points.
You can do this with timer, but it will allow people to just wait for points.
You can also do this by giving extra points every 5 objects destroyed.

You would have to create a Global variable for that too. "ExtraPoints".
You will want to create a Global variable that turns this on and off. "ExPointsEnable"

When the player clicks to upgrade, then you can set "ExPointsEnable" to "On"
(You can set Variables to Text. On/Off)


If you want to use time to give extra points then:
If "ExpointsEnable" is equal to "On"
Then every X Seconds
Add "ExtraPoints" to "Score"

This will give the player extra points every X Seconds. If "ExPointsEnable" is not equal to "On" then it will not add points.


if you want to give extra points for every 5 objects destroyed:
You have to add another variable. "GiveExPoints"
This keeps track of how many objects have been destroyed.

If "ExpointsEnable" is equal to "On"
If object is destroyed add 1 to "GiveExPoints"

If "GiveExPoints" = 5
Add "ExtraPoints" to "Score"
Set "GiveExPoints" to 0

This will give the player extra points every time 5 objects is destroyed.

If you want you can make a Variable to replace the 5.
This will allow you to change the 5 to any other number by just changing the value of that Variable.
By doing this you can easily change how many objects the player has to destroy before getting extra points.
Change the Variable to 6 or even 20. It will only give the player extra points when "GiveExPoints" equals 6 or 20.

Everything you do is about manipulating variable values to make them do what you want. It usually involves simple math, but it can get complicated at times. If a variable doesn't meet a condition you made it won't trigger an event.
If for some reason the player doesn't destroy 5 objects then the extra points won't be added to the score. If the value of "ExPointsEnable" never gets set to "On" then the player never gets the upgrade.
Upgrades are usually just a variable change.

The examples are in Pseudocode.. Meaning I simplified them.

You would use the "System" option for most of them when adding events.
From there you can pick these first as Conditions:

Compare two values
Compare variable
Every X Seconds

After pick a Condition you can add an Action:
Add to
Set Value
Subtract From


That should cover most of it.
B
68
S
37
G
13
Posts: 242
Reputation: 12,787

Post » Sun Dec 11, 2016 3:21 am

I've made a capx that should explain the basics pretty well: https://www.dropbox.com/s/4dtmj1a4y8w3v4g/ClickerGameExample.capx?dl=0
B
27
S
6
G
5
Posts: 18
Reputation: 3,967

Post » Fri Jan 13, 2017 1:32 pm

Thanks for help! it works now :)
B
2
Posts: 2
Reputation: 154


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 0 guests