Additive bonuses

Get help using Construct 2

Post » Fri Apr 24, 2015 5:44 pm

So I'm currently trying to make an idle clicker because I want to teach myself new aspects of C2 (I've only in the past 2 weeks started using it, already made a Tower Defense game for a college project) and I'm stuck quite early in with something simple.
I have it currently so for 10 points, you can buy an upgrade that gives you 0.1 points every second. But I want it so for every 1 upgrade you get, it adds to the bonus.
For example:
1 = 0.1
2 = 0.2
3 = 0.3
And so on...

I bet it's something really simple, but I can't seem to figure it out. Anyone know how I can do it?
B
3
Posts: 4
Reputation: 185

Post » Fri Apr 24, 2015 6:10 pm

Keep a variable to track the bonus rate. When first get an upgrade, it increases to 0.1. For the second, Bonusrate become 0.2 etc. Every second, add that bonus rate to the score.
B
14
S
5
G
1
Posts: 189
Reputation: 1,536

Post » Fri Apr 24, 2015 6:14 pm

bladedpenguin wrote:Keep a variable to track the bonus rate. When first get an upgrade, it increases to 0.1. For the second, Bonusrate become 0.2 etc. Every second, add that bonus rate to the score.

Couple things. Firstly, your grammar made it quite hard to understand this. Secondly, variable? Instance or global?
B
3
Posts: 4
Reputation: 185

Post » Fri Apr 24, 2015 11:24 pm

Sorry about the convoluted sentence structure. Cats and programming do funny things to the way I understand things.

Are you tracking bonuses at the instance level or the global level? If you create a new variable for bonus things, it would make sense for it to have the same scope as the rest of your score related variables. I'm guessing global, but if its a multiplayer game you might be doing something different. So you have a new variable, called BonusRate. It starts at 0. Whenever you get a bonus, you add 0.1 to BonusRate and leave Score alone. Every second, you add BonusRate to score. That way, when you first start off, BonusRate is 0 and nothing happens to the score every second. After you pick up one bonus, BonusRate is now 0.1 and 0.1 gets added to your score every second. After you've picked up two bonuses, your BonusRate is now 0.2, and every second you get 0.2 extra points. If you get a third, it becoms 0.3 etc etc etc

A different approach might be to track the number of bonuses picked up so you can ;display it to the player. Then, if you picked up 5 bonuses, your Bonuses variable is now 5, and every second you do Score = Score + Bonuses*0.1, so every two seconds you get a point.
B
14
S
5
G
1
Posts: 189
Reputation: 1,536

Post » Sat Apr 25, 2015 2:26 am

Bladedpenguin has answer this but I will add:

I would put the upgrading in a function so all you have to do is call the function when needed and it does the add to variable and refresh text objects (if applicable), or other related tasks.
Check out my completed games on the Arcade! Capt. Doe Save the Universe! & Clicker Wizard!
B
65
S
17
G
8
Posts: 636
Reputation: 9,333

Post » Sat Apr 25, 2015 3:26 pm

bladedpenguin wrote:Sorry about the convoluted sentence structure. Cats and programming do funny things to the way I understand things.

Are you tracking bonuses at the instance level or the global level? If you create a new variable for bonus things, it would make sense for it to have the same scope as the rest of your score related variables. I'm guessing global, but if its a multiplayer game you might be doing something different. So you have a new variable, called BonusRate. It starts at 0. Whenever you get a bonus, you add 0.1 to BonusRate and leave Score alone. Every second, you add BonusRate to score. That way, when you first start off, BonusRate is 0 and nothing happens to the score every second. After you pick up one bonus, BonusRate is now 0.1 and 0.1 gets added to your score every second. After you've picked up two bonuses, your BonusRate is now 0.2, and every second you get 0.2 extra points. If you get a third, it becoms 0.3 etc etc etc

A different approach might be to track the number of bonuses picked up so you can ;display it to the player. Then, if you picked up 5 bonuses, your Bonuses variable is now 5, and every second you do Score = Score + Bonuses*0.1, so every two seconds you get a point.


The first solution looks like it will work, I'll give it a try later and see what the results are. Thanks!
Edit: Gave it a go and it worked perfectly. Thanks again
B
3
Posts: 4
Reputation: 185


Return to How do I....?

Who is online

Users browsing this forum: Google [Bot] and 11 guests