Techniques for separating game model from presentation

Posted by liortal on Game Development See other posts from Game Development or by liortal
Published on 2012-09-17T22:10:48Z Indexed on 2012/09/18 3:53 UTC
Read the original article Hit count: 282

I am creating a simple 2D game using XNA.

The elements that make up the game world are what i refer to as the "model".

For instance, in a board game, i would have a GameBoard class that stores information about the board.

This information could be things such as:

  • Location
  • Size
  • Details about cells on the board (occupied/not occupied)
  • etc

This object should either know how to draw itself, or describe how to draw itself to some other entity (renderer) in order to be displayed.

I believe that since the board only contains the data+logic for things regarding it or cells on it, it should not provide the logic of how to draw things (separation of concerns).

How can i achieve a good partitioning and easily allow some other entity to draw it properly?

My motivations for doing so are:

  • Allow multiple "implementations" of presentation for a single game entity
  • Easier porting to other environments where the presentation code is not available (for example - porting my code to Unity or other game technology that does not rely on XNA).

© Game Development or respective owner

Related posts about XNA

Related posts about architecture