Tower Defense Indie Game Dev Blog #1: 3D Models and Pathfinding

Published May 15, 2018
Advertisement

About the Game

As you probably have guessed from the title, the game I'm working on is a Tower Defense type of game. At this point I'm still not sure what theme it's going to be in, but I think I will go with military based theme. The game itself is inspired by Red Alert, Robo Defense and Kingdom Rush. For development side of things I'm using Java/Kotlin (mostly Kotlin) + OpenGL and LWJGL with the IntellJ IDEA editor.

3D Models

In the last couple of weeks I've been learning how to make 3D models using Blender. After few days of modelling I got hang of the basics and could model few simple trees, turrets and a car which I then imported into the game "engine".  Here are few screenshots of the models that I have created during those days:

turret

turretScreenshot from 2018-05-14 19-58-12

car.png

 

Pathfinding

I have programmed a pathfinding management system, which uses flood-fill pathfinding algorithm to calculate where the enemies have to go. The way it works is pretty simple. You start by splitting your game map into square nodes and then generating a gradient map which will tell how far away the current node is from the target node. To do this, you firstly start at the target node, assign its value to 0, then for all the neighboring nodes increment their value by 1, or whatever number you want, as long as its a positive number. If the neighboring node is non-collidable, assign its value to something very large, like 999999.

To get the path from the start node to the current node you start at the start node, and select its neighboring node with the lowest value. Then for that selected node, do the same process until you reach node with the value of 0, which will mean that you have reached your target node.

This is how the gradient map looks in my game:

pathfinding1.png

 

Here you can see the numbers at the center of each node which represent its value. The cars are moving towards the surrounding nodes which have the lowest values until they reach 0, that's when they stop.

Okey, so why did I use this method instead of the famous A* algorithm? First of all. This is heck of a lot faster. Instead of always calculating a path each frame for each entity. You just generate the gradient map once, and update it every time an object is placed on the map. The drawback of this method is that all the entities can only go to a single target destination. If you want multiple target destinations, you will have to recalculate the gradient map with different target nodes.

Gameplay

There's not much of a gameplay at this stage of development. As of now all you can do is place turrets, watch them shoot the enemies and that's pretty much it. Nonetheless this is the gameplay footage:

 

 

Twitter: https://twitter.com/extrabitgames
Facebook: https://www.facebook.com/extrabitgames
Website: http://extrabitgames.com

My website: http://extrabitgames.com

6 likes 12 comments

Comments

lawnjelly

This is looking very good already! You can do it as part of the gamedev challenge too, there are several of us making tower defence games at the moment. :)

May 15, 2018 07:23 AM
EddieK
2 hours ago, lawnjelly said:

This is looking very good already! You can do it as part of the gamedev challenge too, there are several of us making tower defence games at the moment. :)

Thank you!

Oh I didn't know there was a challenge like this. Is there a link in which I could read more about this? 

May 15, 2018 10:00 AM
lawnjelly

Is just a bit of fun, but I don't see why you can't put yours as an entry even if you are planning on selling your game after. Rutin, Awoken, Dexter and I are doing games I know of so far. :)

May 15, 2018 12:00 PM
EddieK
43 minutes ago, lawnjelly said:

Is just a bit of fun, but I don't see why you can't put yours as an entry even if you are planning on selling your game after. Rutin, Awoken, Dexter and I are doing games I know of so far. :)

Oh sounds very cool :) I just don't know if I will be able to finish this game by the time the submission date ends. Though I could try making a minimal viable product and submitting that. And then continue working on the game after submission. Anyways, thanks for letting me know. This community is so friendly :D

May 15, 2018 12:48 PM
Awoken
1 hour ago, EddieK said:

Oh sounds very cool :) I just don't know if I will be able to finish this game by the time the submission date ends. Though I could try making a minimal viable product and submitting that. And then continue working on the game after submission. Anyways, thanks for letting me know. This community is so friendly :D

If you do meet the minimum requirements for the challenge you can earn yourself the 'Tower Defence Badge'!  

Great job by the way.  Your turning mechanism is very fluid.  I also like the military theme you're going with.

May 15, 2018 01:54 PM
EddieK
1 hour ago, Awoken said:

If you do meet the minimum requirements for the challenge you can earn yourself the 'Tower Defence Badge'!  

Great job by the way.  Your turning mechanism is very fluid.  I also like the military theme you're going with.

Thanks! I will certainly try to get my game submitted there :)

May 15, 2018 03:55 PM
DexterZ101

Awesome TD development bro ^_^y It's nice to know your using KOTLIN... I'm learning the language but on early stage.

May 15, 2018 04:11 PM
EddieK
37 minutes ago, DexterZ101 said:

Awesome TD development bro ^_^y It's nice to know your using KOTLIN... I'm learning the language but on early stage.

Thanks! I've have been using Java for few years now and then decided to switch to Kotlin like a month ago. And all I can is that it is AWESOME :D Less boilerplate code, operator overloading (especially useful in game dev) and many more things which make programming faster. The only thing that I don't really get is the whole thing about non-nullable objects. I mean I understand how it works, but there are lots of parts in my code where I need to have a null object referance. Anyways, good luck with learning! It is really a great and modern language :)

May 15, 2018 04:55 PM
Rutin

I really like the art work! :) You should be able to meet the min. requirements easily before the due date. I hope you submit an entry! :) Great work!

May 15, 2018 06:57 PM
EddieK
16 minutes ago, Rutin said:

I really like the art work!  You should be able to meet the min. requirements easily before the due date. I hope you submit an entry! Great work!

Wow, thanks! Didn't expect to get such a positive feedback :) I will try to submit an entry, so I better go back to work now :D 

May 15, 2018 07:18 PM
bdubreuil

I found the pathfinding part very interesting!

By the way, which Red Alert did you take your inspiration from? I'm certainly not a huge fan of Command & Conquer and Red Alert :P

May 16, 2018 01:51 AM
EddieK

Just wanted to thank you guys for all the kind feedback, you guys are the best!

40 minutes ago, thecheeselover said:

I found the pathfinding part very interesting!

By the way, which Red Alert did you take your inspiration from? I'm certainly not a huge fan of Command & Conquer and Red Alert :P

Thank you! Although I have played all of the Red Alert installments, I think my inspiration comes from the original Red Alert which I played on my PS1 :D I'm actually thinking of making tesla towers inside my game, just because I loved them in Red Alert so much :D

May 16, 2018 02:31 AM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Advertisement