Using Defold for a RTS game, how far does it scale?

Way back I used to love playing a game called “Cultures: Northland”.
It’s a bit like Settlers. A real-time-strategy game with 2D sprite graphics and lots of micromanagement of economy and units.

Would Defold be suitable to make a game like this?

Looking back, I think Northland was actually quite complex. For example, resources are not just a number in the corner of the screen “100 Gold, 40 Stone, 27 Food”. Instead the game would track dozens of different types of resource and where they are stored.
If a storage building is destroyed, the resources would scatter and lie on the ground.
If a soldier is killed, a little pile of bone is displayed, and his weapons lie on the ground. They are not just baked into some background texture, they are clickable and then tell you something like “1 shortsword”. When telling another soldier to find arms, these discarded weapons can be picked back up. And as the game runs along and battles stretch out, I’d say there might be thousands of these “weapons” game objects scattered across the map.

As the fog of war lifts off a map, you can pan the camera around and watch other viking villages (and other civilizations).
I’d say at any point there are thousands of units walking around and doing jobs.
There are many thousands of game objects, mostly in the form of resources scattered on the map (but visible, clickable, taken into consideration for game logic like pathfinding to building resources).

I assume that this game was originally programmed in carefully optimized C/C++.
How feasible would it be to create a game like this with Defold?
What bottlenecks should I expect? Is there some blocker?

I’d expect that pathfinding is the biggest challenge.
But I think wrapping some navigation grid logic in a native extension would be fun.
I’ve programmed this in C++ before and the support for native extension modules looks excellent in defold.

For the AI, I think Northland did some serious cheating. For example, by magically spawning food and other resources in the warehouses of non-player tribes.
I think I wouldn’t worry about AI for now, and instead tinker with something more like a tower-defense game. You build your own village, but the enemies are just waves of creatures etc.
That seems like a really fun setting where I could experiment with game logic etc.

Managing thousands of objects can become a problem if you’re not careful (and this is true for any game engine):

  • Will you render thousands of objects each frame? Probably not. But if you do it is not really a problem in Defold. Draw calls are batched and we have culling for objects out of view.
  • Will you have thousands of objects that need to process data every frame? Running code for thousands of agents each frame will likely be problematic. But you most likely want to have stuff running on different timers.
    • You can use Lua coroutines to spread out work over many frames.
    • You can use the Defold timer module to start timers and run code when the timers trigger.
  • Two more examples of complex games made with Defold

Sure, pathfinding is typically quite expensive, but you can tweak your pathfinding algorithm and also cache paths between often travelled locations or when the map doesn’t change very often. You can also do pathfinding calculations spread over many frames using coroutines.

3 Likes

And don’t forget to always question your pathfinding approach as well, because there might be a smarter way to accomplish the same thing. For example not all pathfinding needs to be grid-based, and it definitely doesn’t need to run point-to-point either!

I found this to be a great resource: Flow Field Pathfinding for Tower Defense

Approaches like that one can make the number of objects really irrelevant.

3 Likes