RTS Controls in Unending Galaxy

Sector UIThis is a development update. I made good progress regarding the sector map and implemented most of the controls you’d find in a real time strategy game. There’s still a few things missing but that’s more a “doing all the stuff takes time” problem than a coding issue right now.

Enjoy ! 🙂

So, as I said in an earlier post, sector map is accessed by un-zooming the usual view. In this mode, you keep moving controls of your main ship and get a full overview of the sector you are in.

 The look isn’t definitive but it’s readable enough for now. Each ship / factory / station type has its own icon, circles around the icons show to which faction the assets belong (green are player assets while orange are owned by the Drath faction). The light blue square around some of my ships show which ones are currently selected.

Snap32

Left mouse button is used to select objects, the player can “lasso” his ships with the mouse to select several ships at the same time (alternatively, all player ships can be selected with [ctrl]+A).

The right mouse button is used to give order to the selected ships, and it’s context sensitive:

  • On empty space, ships will simply move there.
  • On a friendly object, they will escort the said object
  • On an hostile object, they will attack.

Additionally holding [ctrl] while right clicking will issue an attack-move order, meaning that the ships will move toward the destination and attack any enemy in range. Holding [shift] allows to queue additional orders.

What’s missing (but partially implemented in other parts of the code) is the ability to manage individual groups via hot-keys. There’s still a few additional commands and keyboard shortcuts I want to add for more complex orders (carrier management, patrol loops..), and well, the display is bare bone. But all in all that was way easier to implement than I initially thought it would be. I will probably publish a video in a few days to give you a better understanding of the sector map.

In other news. I implemented carriers correctly. Like military stations, they manage their wings of fighters dynamically according to the threat they are facing. They don’t know how to replace dead fighters yet, though.

I also massively improved both general and battle performances. Beforehand, the game would become sluggish (on my computer) with 10.000 AI objects (ships + stations), the number now goes up to around 20-25k depending on the activity. I also rewrote the AI thread so I can, if needed, reduce the CPU cost of sectors the player is not in by updating them less often. In theory I could even dedicate a second thread to handle ship AI. There’s still a lot of room for improvement, which is good because the AI code will only grow more complex over time.

And last but not least, I fixed the last “game crashing” bug my prototype had, which funnily enough also fixed a small memory leak and improved performances. Three birds with one stone, that’s a rare sight in a debugging process (fixing a bug is usually more likely to create another one elsewhere than fixing side issues). There’s still a few things I need to fix, but most of it is regarding ship behaviors in commands I have written a long time ago and that shouldn’t be very hard to fix once I get around reviewing this part of the code.