Last active
September 23, 2015 22:36
-
-
Save FredrikAugust/62358bfb6b1510f81dcd to your computer and use it in GitHub Desktop.
Moon-adder for Solex
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'''This is a simple script to create moon objects to use with | |
PietDaGamer's space-game. | |
This is the class file | |
''' | |
__author__ = 'Fredrik A. Madsen-Malmo' | |
class Moon: | |
"""Format: | |
PlanetData deimosData; | |
deimosData.mass = 1.4762e15; // KG | |
deimosData.aphelion = 23471; // KM | |
deimosData.perihelion = 23455; // KM | |
deimosData.radius = 6; // KM | |
deimosData.orbitalPeriod = 109123; // SEC | |
deimosData.color = Color(80, 80, 80); // RGB | |
deimosData.orbitingPlanetIndex = 3; // mercury, venus, earth, mars | |
moons.push_back(Planet(deimosData)); | |
""" | |
def __init__(self, name, mass, aphelion, perihelion, radius, orbitalPeriod, color, orbitingPlanetIndex): | |
self.name = name | |
self.mass = mass | |
self.aphelion = aphelion | |
self.perihelion = perihelion | |
self.radius = radius | |
self.orbitalPeriod = orbitalPeriod | |
self.color = color | |
self.orbitingPlanetIndex = orbitingPlanetIndex | |
def get_code(self): | |
return ''' | |
PlanetData {name}Data; | |
{name}Data.mass = {mass}; // KG | |
{name}Data.aphelion = {aphelion}; // KM | |
{name}Data.perihelion = {perihelion}; // KM | |
{name}Data.radius = {radius}; // KM | |
{name}Data.orbitalPeriod = {orbitalPeriod}; // SEC | |
{name}Data.color = {color}; // RGB | |
{name}Data.orbitingPlanetIndex = {orbitingPlanetIndex}; // mercury, venus, earth, mars | |
'''.format(name=self.name, | |
mass=self.mass, | |
aphelion=self.aphelion, | |
perihelion=self.perihelion, | |
radius=self.radius, | |
orbitalPeriod=self.orbitalPeriod, | |
color=self.color, | |
orbitingPlanetIndex=self.orbitingPlanetIndex | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'''This is a simple script to create moon objects to use with | |
PietDaGamer's space-game. | |
''' | |
__author__ = 'Fredrik A. Madsen-Malmo' | |
from classes import Moon | |
brk = '' | |
moons = [] | |
planets = [ | |
['0', 'Mercury'], | |
['1', 'Venus'], | |
['2', 'Earth'], | |
['3', 'Mars'], | |
['4', 'Jupiter'] | |
] | |
while 'end' != brk: | |
name = raw_input('Name: ') | |
mass = raw_input('Mass: ') | |
aphelion = raw_input('Aphelion: ') | |
perihelion = raw_input('Perihelion: ') | |
radius = raw_input('Radius: ') | |
orbitalPeriod = raw_input('Orbital Period: ') | |
color = raw_input('Color (RGB): ') | |
print 'Orbiting Planet Index:' | |
for planet in planets: | |
print planet[0] + ': ' + planet[1] | |
orbitingPlanetIndex = raw_input() | |
moons.append(Moon(name, mass, aphelion, perihelion, radius, orbitalPeriod, color, orbitingPlanetIndex)) | |
brk = raw_input('Type "end" to end: ') | |
codeMoons = [m.get_code() for m in moons] | |
print ''.join(codeMoons) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment