# Python: Random Star System Generator

No game reason for this really – I just like the idea of messing around in a quasi 3D star system using the Traveller vector movement.

The aim is to have a 3D box with all the stars, planets centered on a plane so you move in 2D but the visuals are 3D with all the orbiters having their own size, radius and orbit time so they move around on their orbits over time.

The code part is pretty easy if you simplify the orbits to circles. All you need is a class that has planet size, distance (from star) and orbit length. The orbit length gives you the number of degrees the planet moves per day so all you need is a method that takes a time, adds on the degrees moved and moves the planet’s center point.

class orbiter:
def __init__(self, tup):
self.name = tup
self.distance = tup
self.days = tup
self.dpd = 360/self.days
self.angle = random.randint(1,360)
self.x = 0
self.y = 0

def dodays(self,numdays):
numdegrees = self.dpd * numdays
self.angle = (self.angle+numdegrees) % 360
#print(self.angle)

def dodraw(self):
self.x = self.distance * math.sin(radangle)
self.y = self.distance * math.cos(radangle)
c1.create_oval(self.x+100,self.y+100,self.x+108,self.y+108,fill=’white’,)

which currently ends up as this (unrealistic orbit distances to test)(the button adds ten days)

This seems like it should actually be pretty easy but will wait until I’ve found out about Python’s Pygame module.

#

Got side tracked from this by the urge to do some Travellerized Dark Heresy chargen so that’s next.