In all XNA games you have to create your own Game class that derives from the Game base class. Here is a pattern in which we use the service provider pattern to create a clear structure for our game class.
In many XNA games and samples the Game class does a lot of stuff and is maybe the most complex class of the application. This makes the source code difficult to understand and hard to re-use. We suggest two things to improve this:
…
We have discussed the Service Provider pattern in the last blog post and in this post we will show how to implement a service provider, how the DigitalRune libraries support this pattern, and how to use it in an XNA game.
Implementing a basic service provider with a Dictionary is simple:
The service provider pattern is one of my favorite patterns: It creates clean, slick code when used right - but when used in the wrong places it creates libraries that are hard to use, difficult to understand and a nightmare to maintain. In this blog post we examine the service provider pattern, related concepts, like global variables, services, managers, service providers, contexts and how they can be used in games.
A collection of the most useful blog articles can be found here:
Article Collection (on Documentation page)
DigitalRune is a trademark of Garstenauer Information Technology OG.
Garstenauer Information Technology OG Weingartenstrasse 35, 4452 Ternberg Austria (EUROPE) office@digitalrune.com