# Why doesn't this formula double the value properly?

Making a clicker game: Amount awarded per click not increasing based on how many increasers purchased.

I have a few global variables set up.

global.ramen_1 = 1


This part says how many ramen makers I have, or what my cursor level is, if you purchase another one it goes to 2, then 3 etc...

global.ramen_1_bonus = (global.ramen_1 * 2)


This is the formula that I want to work. If I own 10 ramen makers. Every time I click the ramen picture it is going to increase based on the value of global.ramen_1 times by two. So in theory the more I buy, the higher it should go up when I click it.

I made the ramen image and clicking on it does the following code.

//Increases the amount of money by clicking the ramen
global.money += global.ramen_1_bonus


I have the object that you click that does this code which subtracts from the amount of money you have, but increases the amount of ramen makers you have. And for the time being I just have a static price, nothing that increases yet.

if (global.money >= 10) {
global.money -= 10;
global.ramen_1 += 1;
}


This works perfectly, ramen_1 goes up by one, the money goes down by ten when you have enough.

BUT

After I have 2 ramen makers or global.ramen_1 = 2. The formula does not work.

When I click on the ramen bowl, my money doesn't go up 4 like it's supposed to, it still only goes up by two. Why not?

I think that your issue relates to this formula:

global.ramen_1_bonus = (global.ramen_1 * 2)


This code is setting you bonus to twice global.ramen_1.

If each time you click you increase global.ramen_1 by 1 then you will increase your bonus by 2, that you are seeing.

From the sound of it you want to double the bonus so you would want something like:

global.ramen_1_bonus = (global.ramen_1_bonus * 2)


(After initialising it to 1 initially)

Or :

global.ramen_1_bonus = (2 ^ (global.ramen_1 - 1))


This is 2 to the power of (global.ramen_1 - 1). I am uncertain about the specific gamemaker syntax. But either of those formulas should give you doubling of the bonus.

Where are you running global.ramen_1_bonus = (global.ramen_1 * 2)?

Perhaps you're not calling this line of code after updating global.ramen_1?