Jump to content
  • Advertisement

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

EddieK

854 views

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:

 

 

My website: http://extrabitgames.com



12 Comments


Recommended Comments

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. :)

Share this comment


Link to comment
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? 

Share this comment


Link to comment

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. :)

Share this comment


Link to comment
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

Share this comment


Link to comment
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.

Share this comment


Link to comment
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 :)

Share this comment


Link to comment

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

Share this comment


Link to comment
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 :)

Share this comment


Link to comment

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!

Share this comment


Link to comment
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 

Share this comment


Link to comment

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

Share this comment


Link to comment
EddieK

Posted (edited)

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

Edited by EddieK

Share this comment


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!