November 11, 2011

Update: Space geography

Almost two months since my last update, but I've been busy.  Still lots of work ahead though!

The star system layout code has been re-worked and made much, much more OO-like.  I had to go back and debug it and ended up not remembering how it worked, so breaking up what was a 2000+ line system design class into several smaller classes with self-contained methods and variables helped a lot.

I've also taken a crack at making spiral arms more interesting by adding arm branches that diverge from the main trunk, but so far the results are not very spectacular.  However, this effort lead me to realize a few things:

1) There is no reason to have the star layout in 3D, even relatively flat 3D.  Yes, it adds realism, but it also makes judging distances and moving ships much more complex.  I've decided to flatten out all my galaxies into a 2D plane.

2) By flattening into 2D, I can now much more easily implement some more interesting "space geography" (astrography?) stuff that I've wanted to do since starting.  Stars voids and clusters are just the beginning, and I'm keeping the full list secret for now :).

3) 2D also allows me to better organize the game space.  Rather than picking points out of the ether and working with undefined spaces between stars or other objects, I can now implement a grid system and bring some order to space.  I'm a little concerned about the amount of memory this will take up--some back-of-the-envelope math tells me that a 10,000 star game with 4 galaxies could require as much as 1,000,000 grid tiles, which would take from 30 - 50MB of memory for just the tiles.  Eek.  But a 10,000 star 1 galaxy game would probably need half that or less (as there would be no empty spaces between galaxies), so I have some options to reduce the overall burden on memory.

Ships would not be forced to travel along the grid (they can still move in straight lines any way they need to) but they would be forced to choose a grid tile as a destination--travel paths must always end at the center of a grid tile, which is where anything in that tile resides.

The main benefit of the grid is the ability to organize space and to pick out a region of space relative to other regions.

No comments:

Post a Comment