### Author Topic: How to approach leveling and experience calculations?  (Read 898 times)

#### NateTheGreatt

• Member
• Posts: 83
• Karma: +0/-0
• smell the sound
##### How to approach leveling and experience calculations?
« on: Sat, Jan 7, 2012 »
I returneth to you, Flixel Help Forums, for another challenge I have been posed with: leveling and experience rates & calculations.

Does anyone have any tips/suggestions/examples they can give me that might make my venture into this scary world of maths a bit easier? Not only the math, but the structure of the calculations within my player class.

Really just any tips anyone could give would be greatly appreciated.

Also, if anyone has any experience with damage calculations taking stuff like armor and magic resistance into account, I'd love some input on that, too.
"A designer knows he has achieved perfection not when there is nothing left to add, but when there is nothing left to take away."
-Antoine de Saint-Exupery

#### John Hutchinson (Johntron247)

• Commodore 256
• Contributor
• Posts: 392
• Karma: +1/-0
• I can has lazerz?
##### Re: How to approach leveling and experience calculations?
« Reply #1 on: Sat, Jan 7, 2012 »
The math shouldn't be that hard if you break it up into small chunks.  There are a lot of different ways to do this but I'd suggest breaking the system up into parts and tackling each one in turn, starting with whatever seems easiest to you.
Use floats from 0.0-1.0 to represent resistence.
Damage * resistence = real damage

How it all works together really depends a lot on you, the designer.  There are a lot of different ways to do this sort of thing.  Perhaps with more information about how you want particular parts to work we can provide you with more useful information.

#### wg/funstorm

• Global Moderator
• Key Contributor
• Posts: 596
• Karma: +0/-0
##### Re: How to approach leveling and experience calculations?
« Reply #2 on: Sat, Jan 7, 2012 »
I agree with John it's more a of a design question. I would pick a game I think does it really well, and then try to figure out how they do it and then try to guess why this particular method works so well and what I can do to create something similar that achieves my goals.

For example here's world of warcraft very formulaic approach http://www.wowwiki.com/Formulas:XP_To_Level

Or Bejeweled which takes a more hand-crafted approach http://penny-arcade.com/patv/episode/puzzle-games

With that information I would probably pre-calculate and save an array of experience points required to advance to the next level in the player class. Then each time the player earns xp, add it to an xp:int also stored in the player class and compare it to the experience array entry at currentLevel+1 to see how close the player is to leveling up.

#### test84

• Key Contributor
• Posts: 1328
• Karma: +0/-0
• ت
##### Re: How to approach leveling and experience calculations?
« Reply #3 on: Sun, Jan 8, 2012 »
I think you should do it when you have designer like major parts of your game, if you did, share it with us and we can make suggestions, if not, I strongly suggest you to do so.
blog, twitter, Check out my award winning game, Rot Gut:

#### Raf

• Contributor
• Posts: 268
• Karma: +0/-0
##### Re: How to approach leveling and experience calculations?
« Reply #4 on: Mon, Jan 9, 2012 »
Speaking from a technical point of view instead of a design point of view (cause everybody above is right that the calculations solely depend on the game design), what I did for the upgrade system of my game, is create a stats class that's pretty much just a variable bin, and placed that in my registry.

I first added all upgrades to the player class itself, but that gave problems when starting another game round. With those points in the registry, it makes saving the game alot easier too (just got to save those points. Your engine takes care of their actual meaning. The result is not having to save an entire player object).

It works stupidly nicely, but might be a bit limiting if you're doing multiplayer or such. Still gotta figure out how to handle that. Haven't really thought much about that part yet, but it kinda means you got to send parts of the player object (coordinates, some base stats that aren't changed by leveling or the likes) and some parts of the stats class. In such cases, I guess it's just easier and cleaner to have it all in the player object.