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!

20 comments:

  1. Thank you && Merry Christmas!

    ReplyDelete
  2. Merry Christmas to you too Firefly! Just a quick question about the tutorial. Could you potentially sell towers by using the "Towers.Remove" as opposed to "towers.Add" for building them?

    ReplyDelete
  3. I believe if you look through the source code I just posted it shows you how to sell towers ;)

    ReplyDelete
  4. Thank you very much and Merry Christmas!

    ReplyDelete
  5. This comment has been removed by the author.

    ReplyDelete
  6. I have tried to copy the Selling code, but when selecting a tower I get some error on the "in" part of "For reach tower in towers". What am I doing wrong?

    ReplyDelete
  7. :( is it possible to convert this to java? plzz since no tut on java :(

    ReplyDelete
  8. Excuse me for asking, but is this tutorial for windows PHONE 7? :P, cuz didnt get how to "tap" the screen to for example place a tower etc? :P *sorry for asking N being stupid*

    ReplyDelete
  9. Whats the code for dragging towers on ur windows phone 7? if all those tutorials also works on that instead of just windows :P abit stupid i know but really want 2 know!

    ReplyDelete
  10. Hey man, Great tutorial as I am sure and you have been told a million times, But I am actually still quite early on, but I have an issue which has probably been raised before, but worried you might not still check your older posts. So here it is:

    It's been a problem since the first tutorial on my machine, but if you try and give the enemy a speed of over 2, it gets stuck at the first waypoint, and doesnt progress forward.

    It seems as though it is going past the waypoint, due to the speed of say 3f, and then when it is checking the distance it is returning 1f, as it is at (64,33) instead of (64,32) and thus it is not dequeueing it. So I tried making it < nf where n is my speed which solved it.

    I'm sure you have already covered this but I just thought that someone else might be having the same problem.

    ReplyDelete
    Replies
    1. That is

      if (waypoints.Count > 0)
      {
      if (DistanceToDestination < nf)
      {
      ...
      }
      }

      in the enemy update function

      Delete
    2. Sorry, if (DistanceToDestination < speed) is better as both are floats, and that allows for slower or faster enemies

      Delete
  11. Thanks for pointing that out, I'm not sure if I had covered it before so I stuck it in a blog post! :)

    And Chris E the tutorial code should work on Windows Phone no problem, just drag the tower icons to place towers! Although this code probably won't due to the menus but it shouldn't be hard to drop the Phone version of the GSM sample into the project!

    ReplyDelete
  12. The link to the game is dead

    ReplyDelete
  13. I know you said you weren't going to proceed with the Tower defense tutorials, but can you please show how to transform this project to be able to run on the windows phone? The only thing that needs to be changed is the usage of XMLDocument to Xdocument and same with the XMLNodes, but I am not able to convert them myself properly=/

    ReplyDelete
  14. Hi great tutorial. You mentioned about a level editor in tut 1, then in tut 2 you wrote that you would take that tutorial in the end. I seem to have missed it somewhere (I really can't find it D:). Could you show me where it is? :o

    Thanks for making such a nice tutorial. Great way to learn making cool games. Hope to see more out from you in the future.

    ReplyDelete
  15. hi, I tried download this merry christmas file but in my microsoft visual c#2010 express, it comes up with errors like this:
    Error 1 The type or namespace name 'Xna' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?) C:\Users\Vincent\Desktop\LANE DEFENCE NEW PROJECT\TowerDefence\TowerEditor\GraphicsDeviceService.cs 13 17 TowerEditor

    Can I know why this happen? and how to solve it? thanks

    ReplyDelete
  16. Hi Wai Leong,

    Can you confirm that you have Xna installed? You can download it from here if not:

    http://www.microsoft.com/en-gb/download/details.aspx?id=23714

    ReplyDelete