Starfield Layout

Posted by

The starfield is the first thing you see when you start up the game. The way I see it working is, the first time you log on, the game will find an area of space which is currently free of other players. The idea is, it takes a while for a player to colonize an area, so by finding some empty space for you, you don't have to worry about another, more advanced, player from taking over all the stars in the vacinity while you're just finding your way around.

Basically, the "universe" is going to be randomly generated, and it's going to be infinitely big. To make things simpler for me in various respects, the universe will be divided into "sectors" which which an area of around 512x512 pixels. The sectors will be identified by coordinates with (0,0) being the centre of the universe.

Each sector will be divided into a 16x16 grid, with each grid location being 32x32 pixels. Inside the grid will be zero or one star, with the idea being that there will be, on average, about 20-30 stars in a sector. I'm going to keep the number fairly low to begin with, because I want to leave open the possibility of randomly generating new stars in all of the sectors (for example, if I decide on a new "kind" of star or something).

Basically, it'll work something like this:

Starfield Layout

As you scroll around, the game will load up the sector that's currently visible on your screen plus the surrounding sectors. It'll unload sectors as they go out of view and load new sectors as they come into view. In this way, we can have an infinite universe, but only ever need to have a fixed amount of data loaded at any one time.

Sectors will be largely invisible to the player. Also, the stars will not be placed in the very centre of the grids, they'll be randomly placed within the grid. That way, the stars will appear to be fairly randomly spaced, but they'll also never be so close as to be overlapping.

As I mentioned above, when you first start, you'll be allocated a random piece of "empty" space. In this case, "empty" means a sector where no players have taken over any stars. So the very first player to join the game will get the sector at (0,0). The second player to join will get maybe (0,1) or (1,1) or one of the sectors around (0,0). And so on, expanding out as new players join.

Players will invariably leave the game as well. I'm thinking there should be some kind of "decay" value on your planets so that if you don't do "something" to maintain them, then eventually they go back to the default "uninhabited" state. In this way, a player who joins the game, plays for five minutes then gives up isn't going to take over a whole sector forever – eventually the unused sectors will be reclaimed and can be reallocated to new players again.

blog comments powered by Disqus