#!/usr/bin/env python
import numpy as n
import subprocess as s
import os as o
import body as b
import map as m
planets = []
# earth
B = b.Body(60,0,0,4.5,.2)
planets.append(B)
# mars
B = b.Body(-100,0,0,-6,.08)
planets.append(B)
# saturn
B = b.Body(0,200,6,0,10)
planets.append(B)
# sun
B = b.Body(0,0,0,0,6e3)
planets.append(B)
max_mass = 0
for B in planets:
max_mass = max(max_mass,B.mass)
M = m.Map(max_mass=max_mass)
for i in range(300):
for B in planets:
for BB in planets:
B.gravitate(BB)
for B in planets:
B.move()
M.draw_body(B)
M.draw_map()
s.Popen('mencoder mf:///tmp/frame*.png -mf w=600:h=400:fps=10:type=png -ovc lavc -lavcopts vcodec=mpeg4:mbd=2:trell -oac copy -o /tmp/output.avi && mplayer /tmp/output.avi', shell=True)