It's time I posted another progress report.
Since my last progress report I have implemented most of the features from my feature list. I'm not entirely happy about the Xaml support for level design, and I am still missing the support for per-pixel collision detection, but the game engine works well enough that I have implemented a VERY simple game using it.
The game, available here, lets you control your character on a field throwing swords at some monsters. You get points for how many monsters you kill and if you are touched by a monster you die.
As simple as it is the game demonstrates the features needed for a proper game:
- We have collision detection - both between moving sprites (character, monster, sword) and between sprites and background (you cannot walk across mountains).
- We have animation support and an animated sprite can have many animations that we can choose.
- The game area and all game assets are defined in Xaml.
- Graphics are reused between sprites. This means that two identical monsters share the same bitmaps in memory.
The engine is still missing some features. The most obvious one is the pixel perfect collision detection. This is a simple feature to add, but I fear that it will be a real performance killer so I postpone it until I really need it. Apart from that I feel that the framework surrounding game setup needs some work.
The current implementation lets you define one or many GameAreaGrid objects. The GameAreaGrid lets you place one rectangular sprite in each cell. You then tell the Viewport to load the grid and it will be setup as the background area of your game. To change maps you tell the viewport to load another GameAreaGrid object.
While this works well enough I would like it to be even simpler to use.
The idea is to add support for area transitions to cells in the GameAreaGrid so that when the player enters one of these we automatically loads the new grid and places the player at the new location. This should allow us to setup an entire game world using only Xaml. I'm not entirely sure what would be the best way to define an area transition but I think it would be nice to add an AreaTransitions collection property to the GameAreaGrid where each object in the collection described a transition that would be performed when the player enters a given cell. A transition would be from a cell (grid row and column) to a new cell in another GameAreaGrid. The reference to the GameAreaGrid would be a regular object reference that could be modeled as a binding to a StaticResource in Xaml. This still gives us the option of designing the GameAreaGrid in Xaml or in code if we prefer.
I would also like to allow random placement of enemies in a GameAreaGrid. Either completely random or by identifying cells where mosnters can spawn. The types of monsters, the number of monsters and how often they spawn would also have to be specified.
So that will be my plan for the week until christmas. Implementing more support for game mechanics, paving the way for a complete game engine :-)