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.
def __init__(self, tup):
self.name = tup
self.radius = tup
self.distance = tup
self.days = tup
self.dpd = 360/self.days
self.angle = random.randint(1,360)
self.x = 0
self.y = 0
numdegrees = self.dpd * numdays
self.angle = (self.angle+numdegrees) % 360
radangle = math.radians(self.angle)
self.x = self.distance * math.sin(radangle)
self.y = self.distance * math.cos(radangle)
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.