Wednesday, 7 March 2012

WANTED : More Tutorials?

Hi guys,

It has been a while since I wrote any tutorials, mainly due to lack of time, but partly due to lack of inspiration... hopefully you can help me out here!

What tutorials would you like to see written? (just to get it clear now, I am NOT writing a series on how to make an FPS, an RTS, an RPG etc... a whole book would most likely be too small for this... ;) )


Thursday, 2 February 2012

Bug Fix : Tutorial 4 - Waypoints

As has been pointed out in the comments, in the fourth tutorial we added some code to check if the enemy has gotten close enough to the way point to move onto the next. This works well if the enemy is moving with a speed <= 1, however not so great if it moves with a speed of 2 for example.

To fix this we simply change :

if (DistanceToDestination < 1.0f)
{
    position = waypoints.Peek();
    waypoints.Dequeue();
}

to :

if (DistanceToDestination < speed)
{
    position = waypoints.Peek();
    waypoints.Dequeue();
}


Thanks for pointing this out Ryan! This was what I had intended to write but for some reason left the speed hard coded...

Sunday, 25 December 2011

Merry Christmas!

As a very big thank you to all of those that have read this blog and helped improve it by pointing out my mistakes, I have decided to release an older version of my personal tower defence!

It includes two different types of pathfinding, one that helps the enemies get to the end of the level, and one that detects if the player is “blocking”.

The algorithm used to get the enemies to the end of the level is a variant of the breadth first algorithm. The algorithm generates a direction for each tile which points to a neighbouring tile. The neighbouring tile also contains a direction to a neighbouring tile; eventually if you just keep following the directions you follow a path to the goal!

It also includes a basic level editor, however you will only be able to save levels using the shortcut Ctrl + S, though the code to load the levels is included!

Just be warned the game isn’t at all balanced! Winking smile

So here it is, Merry Christmas!

Saturday, 10 December 2011

A* Pathfinding Tutorial : Part 3

Welcome to the final part of the A* pathfinding tutorial! In this tutorial we will be implementing the algorithm I described in part 2 in code!

At the start of this tutorial we will be adding some useful properties and methods to the SearchNode and Pathfinder classes that will make writing the FindPath method more simple.

Then to finish off I will post the full code for FindPath method indicating which piece of code relates to which step of the algorithm posted in the last tutorial!

Edited on the 10/12/2011 at 8:00pm

Thursday, 4 August 2011

A* Pathfinding Tutorial : Part 2

Welcome to part two in my series on pathfinding. In this tutorial we will be looking at the actual A* algorithm before we actually start implementing it in code in the next tutorial.

This tutorial will be mostly theory based with very little coding so please stick with it as it is really important to understand the actual algorithm before trying to translate it into code!

Sunday, 26 June 2011

A* Pathfinding Tutorial : Part 1

Welcome to part one of my two part series on path finding!

In this first part we will be looking at the amazing A* (A-Star) pathfinding algorithm which is probably one of the most precise and performance friendly pathfinding algorithm out there at the moment.

In part two I am going to show you that although A* is great, that it isn’t always the best algorithm for the job. I will be showing you how we can add pathfinding to the tower defence game made in the previous series using a Breadth First algorithm.

Friday, 8 April 2011

Tutorial 15 : Adding Health Bars – Extended

Up until now, we use the enemies colour to represent his health, and while this works quite nicely for our little black blob, it doesn’t work so well with more complex sprites.
In this tutorial we are going to add little health bars that will float above our enemies heads. A lot of the code in this tutorial has been inspired from George Clingerman’s amazing tutorial on health bars. So if you are struggling with this tutorial, I would recommend reading his first as he explains it in more depth than I will.