When I decided to implement gnome migration into your city in Gnome Mountain, I needed to come up with a world clock class, I came up with a pretty cool event based class that is very simple to implement and turns out to work very well.
Here is the code for the class: http://mage360.pastebin.com/9sNdwEjb
And here is an example of implementation: http://mage360.pastebin.com/b0yBYwtn
Tuesday, November 2, 2010
Tile edge detection for a smooth environment.
I found a great new artist for the Gnome Mountain project, and with that came new tiles for my environment, which meant I needed to add edge detection to make a smooth and better looking world.
Here is what the new Gnome Mountain is looking like with edge detection, new tiles and also new sprites: http://i52.tinypic.com/ny5t6w.png
For anybody that is curious, here is the code I use to detect edges: http://mage360.pastebin.com/6gEe3McP
Here is what the new Gnome Mountain is looking like with edge detection, new tiles and also new sprites: http://i52.tinypic.com/ny5t6w.png
For anybody that is curious, here is the code I use to detect edges: http://mage360.pastebin.com/6gEe3McP
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
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
Updated AStarPathfinder class: http://mage360.pastebin.com/ckXfaeBB
Gnome Mountain Implementation (GnomePathfinder.cs): http://mage360.pastebin.com/nrBdV2GQ
Friday, February 26, 2010
AStarPathfinder
I've created an extensible and fairly simple implementation of A* pathfinding for the PandaXNA engine.
Video:
http://www.screentoaster.com/watch/stWE5RRUdIR19YQVRfWllcUVJc/simple_a_pathfinding
Here is the class:
http://mage360.pastebin.com/34xSMVby
Here is the implementation in Gnome Mountain:
http://mage360.pastebin.com/2QaAgT9p
Example of usage:
pathFinder = new GnomePathfinder(world);
pathFinder.initialise(worldRect.Width, worldRect.Height);
testPath = pathFinder.generatePath(new Vector2(0, 49), new Vector2(3, 35));
In case anybody is wondering about the basic theory behind A* pathfinding, here is a cool tutorial I found lying around the internet. It's very easy to understand and very informative: http://www.policyalmanac.org/games/aStarTutorial.htm
Video:
http://www.screentoaster.com/watch/stWE5RRUdIR19YQVRfWllcUVJc/simple_a_pathfinding
Here is the class:
http://mage360.pastebin.com/34xSMVby
Here is the implementation in Gnome Mountain:
http://mage360.pastebin.com/2QaAgT9p
Example of usage:
pathFinder = new GnomePathfinder(world);
pathFinder.initialise(worldRect.Width, worldRect.Height);
testPath = pathFinder.generatePath(new Vector2(0, 49), new Vector2(3, 35));
In case anybody is wondering about the basic theory behind A* pathfinding, here is a cool tutorial I found lying around the internet. It's very easy to understand and very informative: http://www.policyalmanac.org/games/aStarTutorial.htm
Saturday, February 20, 2010
BasicCamera2D
Another part of the game engine developed with the Gnome Mountain mini-project. This is a basic 2D camera class that can be easily extended.
Source:
http://mage360.pastebin.com/f3798a7d8
You'll also notice that the engine classes have been moved to a new project and namespace called "PandaXNA". This is now the name of the game engine that will be used by M.A.G.E.
Source:
http://mage360.pastebin.com/f3798a7d8
You'll also notice that the engine classes have been moved to a new project and namespace called "PandaXNA". This is now the name of the game engine that will be used by M.A.G.E.
Attribute tag personality
With my Gnome Mountain mini-project (using this to build up all the 2D parts of the game engine) I've decided to develop an attribute tag based personality system. This will be used for the Gnome AI.
The personality class:
An example of the use, checking if a gnome is a miner and finding him a job:
if (gnome.personality.hasAttribute(PersonalityAttribute.Miner))
{
if (findMiningActionForGnome(gnome, world))
return;
}
The system basically works using a Dictionary< Attribute, Skill Level > collection.
The system basically works using a Dictionary< Attribute, Skill Level >
Subscribe to:
Posts (Atom)