Starfield-map Generator


#1

I made a little python script that will create a 2048 x 2048 image (the size of GSB maps) and then randomly populates it with stars. It is written in JES (Jython Environment for Students) however, so you will need to install that and Python to run it. Here is the code if interested:

[code]import random
def main():
starlist=createStarfield(requestIntegerInRange(“How many stars would you like to create?”, 0, 5000))
saveImage_question=requestString(“Save Image?”)
if saveImage_question==“Y” or “Yes” or “y” or “yes”:
saveImage(starlist[0])

def createStarfield(numStars):
pic=makeEmptyPicture(2048, 2048, black)
outputList=[pic]
for n in range(numStars):
x=random.randrange(0, 2048)
y=random.randrange(0, 2048)
addRectFilled(pic, x, y, 1, 1, white)
#addRectFilled(pic, x+1, y, 1, 1, Color(63, 63, 63))
#addRectFilled(pic, x, y+1, 1, 1, Color(63, 63, 63))
#addRectFilled(pic, x, y-1, 1, 1, Color(63, 63, 63))
#addRectFilled(pic, x-1, y, 1, 1, Color(63, 63, 63))
outputList.append(x)
outputList.append(y)
repaint(pic)
return(outputList)

def saveImage(pic_input):
writePictureTo(pic_input, INSERT PATH HERE IN QUOTES)[/code]
The commented out lines were parts that I thought would enhance the picture, but in reality made it look weird.

And then something that I did with a starfield generated by this script and GIMP yesterday:


The starfield was actually made using an earlier version of the script, in which the image it generated was only 800 x 800. I still can’t figure out why JES puts in the little gray bits; I commented those lines out, and besides, if thy weren’t then they would be drawn in different places. Oh well.


#2

You must like rather small maps, then!

Thank you for creating this resource, Wasabi. This should prove useful for authoring new scenarios. :slight_smile:


#3

That looks great! Any chance of adding in planets? Or Specification’s e.g. lots of big blue stars?
Thank’s allot anyway! It takes ages to find a space background of the correct size withought cutting up or stretching!


#4

Possibly. I’m no expert programmer, I actually made the original program in the Computer Programming course at my school then adapted it for GSB maps. I can make the stars in the background varying colors (light blue, red, orange, etc.) and later I may even be able to add some sort of nebulous formation. Planets, as well as those nebulas, I don’t know about. Hmm… Make a sphere, add random colors… I’ll play around with it. Thanks for the feedback!

Edit: Like I said in the OP, I made the star with GIMP. Specifically, I used Filters/Light and Shadow/Supernova. Play around with supernova a bit and you should have a nice star soon enough :slight_smile:

Edit again: I had the idea last night of using the Supernova tool to make bullet textures. Just thought that might be worth a mention.


#5

Fiery star bullets! :smiley: