< Guide to Game Development < Miscellaneous

Programming XP - Avoiding overflows

In a traditional game, the higher your level is, the more XP you'll need to get another level up. The problem with a basic approach to this is that you could very quickly run into stack overflow problems.

Example of bad code with overflows

Example of fixed code without overflow problems

References

    This article is issued from Wikibooks. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.