Many games (such as my own Pixel Blacksmith and Blacksmith Slots) contain an XP / level system, where performing actions will reward experience, and eventually new levels. These new levels often unlock new content, or provide currency, so keeping players incentivised without feeling like a “grind” is a tricky balance.
First, come up with a basic formula to use for calculating the XP required for a level. The most common by far is
x affecting the amount of XP (lower values = more XP required per level), and
y being how quickly the required xp per level should increase (higher values = larger gaps between levels).
Next, make a spreadsheet where
y can be quickly and easily modified, and the XP per level seen. Here is my spreadsheet, feel free to make a copy.
As an example, here’s a comparison of the XP required for levels using varying values of
y. Note that using 2/3 for
y is recommended, so that built in squaring / cubing functions can be used.
This has a fairly quickly increasing amount of XP per level (
y) and a large amount of XP (
x), and is good for games where XP is relatively easy to gain.
This has a high value for
x, so the amounts of XP required for a level up are very small. This would be good for a game where XP is relatively hard to obtain (e.g. requires collecting items). Note that the % increase in XP between levels 1 and 2 is the same as Example 1 (3x higher).
This uses a different value for
y than the other 2 examples, and as such the XP required rapidly increases. This would be used in a game where higher levels have significantly higher XP gaining potential (e.g. an incremental game).
Now that we have a formula for XP required for any level (using Example 1:
XP = (level/0.07)^2), we also need to know the current level based on XP. Inverting the formula gives us
level = 0.07 * √XP. The second formula can be harder to implement due to requiring “nth root of”, hence why using a value of 2/3 is recommended.
XP and levels can now be converted easily and efficiently, without requiring any lengthy formulas. However, how useful the formula will be depends entirely on how well the
y values are tuned for the specific use case. Get it wrong, and players will power through content or complain about being too grindy, get it right and they’ll never mention it!
Levels are an extremely common way of rewarding consistent players, and providing an incentive to continue playing the game, or to replay older content. Balancing the formula is extremely important, and the simplicity of the formula described in this post means that consistent complaints of level ups being too frequent or too infrequent can be fixed by changing a single variable.
It is applicable to pretty much any game on any platform, but is especially useful in mobile applications, where processing power can be more limited, and player attention harder to keep.
A gist of a Java implementation of converting between XP & levels, as well as calculating current % progress towards next level is available here.