Sunday, March 21, 2010

Event based KeyboardManager

I've written a keyboard manager class that calls events when a keyboard key is pressed, it uses the C# version of function pointers, called "delegates". It makes input handling much easier and cleaner, and provides events that are more useful than the raw XNA keyboard checking.

Class: http://mage360.pastebin.com/bRX9qd2s

Implementation example: http://mage360.pastebin.com/dAgsCEkn

Sunday, March 7, 2010

AStarPathfinder Implementation - Custom collisions and terrain.

I previously posted a customizable AStarPathfinder class for my PandaXNA game engine. Here I'm going to post an example of how it is implemented into Gnome Mountain in a customized way. The gnomes need to use ladders to move up and down in the game, but of course the PandaXNA engine doesn't know this, and it doesn't need to know. By implementing the getNodeMovementPenalty function in a derived class, you can specify how movement and collisions work in your game, while still using the core path finding of PandaXNA.

Updated AStarPathfinder class: http://mage360.pastebin.com/ckXfaeBB

Gnome Mountain Implementation (GnomePathfinder.cs): http://mage360.pastebin.com/nrBdV2GQ