General Principles

Loading Data via XML

A general principle behind the architecture of this project is to separate as much as possible the particulars of external content from the details of code. Take, for example, this Sprite constructor:

This monstrous line of code is difficult to read and to modify, and it contains numerous magic numbers which are unique to each content item (texture, animation, sound, level, etc). Rather than having such data defined at its basest level along with the along with code which will be used directly by the client, it should be centralized in one easily expandable place. Additionally, this approach makes it much easier to efficiently control the loading of external data, and it requires the explicit decoupling of sprites, textures, and animations from each other.

The specific implementation I'm using is XML. The ContentManager class has the ability to load content into memory as needed. For efficient use of memory, it can be instructed to load only a certain set of content based on which XML files it is given. Any content that is to be used in the game must be represented in XML. The earlier Sprite constructor, when accompanied by XML data, is much simplified:

Ripping off XNA

Many of the concepts and classes I've implemented are inspired by XNA. The implementation is, of course, my own, but the names of many classes and their general design mirror XNA, as well as the .NET framework, in many ways. I'm attempting to keep the aesthetic similarites between XNA and my own framework intact wherever it best suits this project, for a number of reasons:

  1. XNA is well-designed, tried-and-true, and ideal for game programming
  2. Renaming objects whose direct inspiration is XNA and otherwise muddling their origins would be a waste of time
  3. Preserving similarities in structure and naming makes it easier to transition between this project and XNA