Additive bonuses

0 favourites
  • 6 posts
From the Asset Store
This is a source code sale for the game "Mega Bonus 777 Casino Game Html5"
  • 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?

  • 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.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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?

  • 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.

  • 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.

  • 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

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)