JeffreyDriver

So I'm working on an upgrade system and I want players to be able to buy multiple levels at the same time.

For instance either 1, 10, 25 or 100 levels depending if they have enough currency. How on earth do I calculate that?

The cost of items is based upon it's current level (current level X current level X fixed value) So 1 x 1 x 10 = 10, 25 x 25x 10 = 6250.
Current Projects:
The Grand Grimoire Chronicles Episode 1 now on Kongregate!.
I always appreciate useful feedback. Thank you.
www.jeffreydriver.co.uk

merrak

The sum of the first N squares is given by the formula

sum = (1/6) * N * (N + 1) * (2N + 1)

which you can multiply by the fixed value to get the cost of the first N levels.

sum = Fixed * (1/6) * N * (N + 1) * (2N + 1)

So you can use the formula to compute the cost to upgrade from level 0 to level N.

To compute the cost to upgrade from level M to level N, you would need to subtract the sum of the first M levels from the sum of the first N levels.

sum(N) = Fixed * (1/6) * N * (N + 1) * (2N + 1); sum(new level) - sum(current level)

JeffreyDriver

Okay,  thanks merrak.
Current Projects:
The Grand Grimoire Chronicles Episode 1 now on Kongregate!.
I always appreciate useful feedback. Thank you.
www.jeffreydriver.co.uk

JeffreyDriver

I'm still not getting this. Would you, or someone else please be able to show me that first formula as code blocks?
Current Projects:
The Grand Grimoire Chronicles Episode 1 now on Kongregate!.
I always appreciate useful feedback. Thank you.
www.jeffreydriver.co.uk

vicevicebingo

+repeat loop count

without using do after 0.01 second block
set buy level price to buy level price + check level price

sound funny wrong yeah

merrak

Here's what I came up with. N is the target level,  c is the fixed cost multiplier, and l will be set to the cost to buy from level 0 through level N.

JeffreyDriver

Thanks again merrak. I really appreciate it. It appears to be working and I actually understand it a lot better.
Current Projects:
The Grand Grimoire Chronicles Episode 1 now on Kongregate!.
I always appreciate useful feedback. Thank you.
www.jeffreydriver.co.uk