DefGraph

#1

Hello to everyone in defold land :smiley:
I wanted to show you guys what is I’m working on right now, before that I should tell that I am a c# and .net developer but from a long time ago I was always interested to make games and I made two or three ones with unity some years ago. newly I looked for new game engines especially 2d focused ones and I found defold, I did look at Godot and it is support c# (kinda) but Lua and defold are just amazing, not to forget it has an amazing community. so I tried to put myself on a learning curve of learning Lua and defold with building my module extension and it was a challenge for me to get my mind of .net and visual studio land to Lua :woozy_face: but the more I worked with Lua the more I loved it.
so this is my first try at building something from ground up with defold, DefGraph extension.

In this extension, I have 3 modules, one for building graph, one for drawing debug info and one that takes care of moving inside the graph.
You can define a graph with several nodes and routes between them and the extension takes care of finding and moving your go inside this graph with just one call inside player update function.
the gif bellow shows you this exactly when the destination for all red circles is node number 6. (if you saw some interruption in moving circles it’s because of recording quality, not the actual performance)

As you can see staying on the routes is the number one rule for red circles and they are going to the destination with minimum distance. all you have seen in this gif except for red circles, drawn by defGraph debug module and all of them are customizable using global variables from colors to sizes.
defGraph is adaptable to map change so even if you add or remove routes in the middle of the game extension tries to find the better road for you.

So the reason I showed you guys this is, in the end, I wanted to open source this extension to community and before that, I want to do some cleaning up in source code and get your advice about improving performance and writing better code especially for modules, I’m thinking to combine these 3 modules, it seems passing data between them cause performance to drop a bit, or am I wrong completely and I haven’t played with defold profiler yet.
thank you all for your time and attention.

PS: sorry if this post is a bit cheesy, I’m still improving my English writing :wink:

17 Likes

#2

Welcome to Defold and thank you for sharing what you’re working on! It looks really cool!

It depends on how you pass data. You can use our buffer system which allows you to pass large data structures between Lua and extensions in a performant way.

5 Likes

#3

sounds interesting, can you guide me to its documentation?

also, I learned that storing math functions in a local and use them instead is faster than calling them repeatedly like:

local sin = math.sin

and use sin instead of math.sin
this kinda things maybe make sense but it blows my mind. I’m looking for these types of performance tips.

0 Likes

#4

And also for the C counterpart:

3 Likes

#5

Defgraph is now publicly released and available to use in github.
I’ll gladly welcome every PR and suggestions from you.

5 Likes

#6

Cool! You should submit it as an asset to our asset portal as well!

3 Likes

#7

@britzl I did add an issue on awesome-defold, thanks

3 Likes

#8

version 2 is out now with several improvements on performance and usage of functions and debugging
see Changelog and migration guild from version 1 to 2 for more info

1 Like

#9

DefGraph version 3 is now released with a lot of features added to it like object rotation tracking, curve routes, one-way routes, dynamic nodes, etc.
As always your feedback would be greatly appreciated.


5 Likes