Click to See Complete Forum and Search --> : Level system for game


kaloer
January 30th, 2010, 03:47 PM
Hi there!

A friend an I are developing a game in which we want a level system. You start in level 1, then level 2 etc.

The current level should be calculated from number of points the player has. The difference between two levels should increase more, as bigger level the player is.
For example:
Level 1: 0 - 100 points
Level 2: 101 - 250 points
Level 3: 251 - 450 points
etc.

We could write every level difference in an xml file or so, but we do not want a limit on the levels. Therefor, I would really like to know what I should do to calculate the level!

Thank you very much!

//Kaloer

Zachm
January 31st, 2010, 01:15 AM
From the example you gave it seems that in order to advance from level i to level i+1, the player must gain an additional 100+(i-1)*50 points:
example:

From level 1 to level 2: 100 + (1-1)*50 = 100
From level 2 to level 3: 100 + (2-1)*50 = 150
From level 3 to level 4: 100 + (3-1)*50 = 200
...


Therefore, the total number of points required to advance from level k to level k+1 can be calculated by:

1 + Sum{i=1 to k} ( 100 + (i-1) * 50) =
= 1 + 100*k + 50 * Sum{i=1 to k} (i-1) =
= 1 + 100*k + 50*k*(k-1) / 2 =

= 1 + k*(100 + 25*(k-1))


So, for example, in order to advance from level 3 to level 4, the player must gain a total of:

1 + 3*(100 + 25*(3-1)) = 451 points


Regards,
Zachm

kaloer
January 31st, 2010, 02:54 AM
Thank you very much! It works very good.

//Kaloer