Update 240309


Navigating the Globe

With the decision to make a large world map comes a little complication when it comes to pathfinding. The map is 8k x 4k tiles big. That is 32 000 000 tiles! And you want to be able to send a unit from one corner of the world to another. There will be naval units, so the pathfinding has to work both for land ,sea and rivers.

A traditional approach of searching all adjacent tiles would simply consume too much memory and CPU time.

A solution to this problem is hierarchical pathfinding. The entire map is covered with a grid of nodes further apart with connectivity information. This process can be automated.

When you search for a path over a short distance, e.g. within the scope of several ground level screens, you do a direct search on map tiles. If you want to find a path across the entire continent, you do the search on the larger scope nodes grid. 

Real world analogy would be finding a route within your city vs. finding a route across the state. When you navigate in your city, all you need is a local map with small streets and roads. However, if you know your destination is in another city, you take another map with highways to plan your route. You use the highways map to lay out a rough plan which cities you have to pass. And small scale local street maps to know how to connect the highways.

This method is as good as good is the node grid. Ideally the node grid should be manually designed. For now I use automatic generation. Units sometimes take a short “detour”. The system can still be tweaked and optimized, but I am pleased with the overall performance.

Navigating the masses

Another challenge I had to overcome was the intended number of units. I wanted the player to be able to select and manage a large number of units even in the global view. But if you zoom out, you can not display all units at once. They would be too small and densely packed together. I decided to divide the map into districts and group units in each district. In the global view, you see an icon representing a group of units that you can select and give orders to.

Things you can do

  • You can start a new game and select a suitable spot with the surrounding land statistics.
  • You can select and move units around the map.
  • You can send units to cities and liberate houses to get more units.
  • You can build a small camp.

In the next update

Next step is implementing the resources system and proper building construction.

Files

Facteroids2itch.zip 119 MB
62 days ago

Get Facteroids 2

Leave a comment

Log in with itch.io to leave a comment.