Space Traders

          So one of my projects this term is a game where you fly a space ship from star to star trading goods. The game itself has no explicit goals. One of the key points of the game is that the economy shift as you trade. When you buy goods in a location the price there increases and when you sell them the price decreases in hat region. At the same time, other traders are wandering the galaxy performing their own trades, so some times you will get back from a long trade route and find that the price of  good has changed a lot while you were gone.
          One of the key aspects of the game is that each planet in the galaxy has its own image, all of which are procedurally generated… 

To do this, first I create an array of blank bitmaps to use as color fills in the draw circle function in AS. Then each bitmap is filled with pixel colors taken from an array. The arrays are each 100 entries long and the program takes a random walk through the array to select the colors. Every step through the array is used to set the color of two pixels, and the arrays are set up so that two adjacent positions are likely to have the same or similar colors. These two things combine to make sure that there are relatively large color features on the selected planets. If the walker gets to an end of the array, it is placed in a random position in the interior. My arrays aren’t perfect, but the better the array the more interesting the resulting planets. The more colors you have and the further those colors are from each other, the more likely the planet is to look like it is tv static. The format I’m using is:

[“array_name”, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, …, 0xCCCC00, 0xCCCC00]

With 100 hexadecimal entries defining that array’s pallet and the relative frequency of colors and the name in the zero position telling me what the goal for that array is.

Previous Post
Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: