Example #1
0
def main():

    # load in the images for all the planets
    # like hitting ctrl+r and loading your blitz
    suni = load_image("sun.png")
    merci = load_image("mercury.gif")
    venusi = load_image("venus.gif")
    earthi = load_image("earth.png")
    marsi = load_image("mars.png")

    # initialize all the planets as an object
    # hope that the values are all correct
    sun = Body(1.98892e30, 0, 0, 0, 0, 12, 1, 1, 0,suni,17,17,0,17,17)
    mercury = Body(.06*EM,0,.3871*AU,47890,0,3,1,0,0,merci,8,8,.2,16,16)
    venus = Body(.82*EM,0,-.7233*AU,-35040,0,8,0,1,0,venusi,10,9,.3,20,18)
    earth = Body(EM,AU,0,0,-29790,6,0,0,1,earthi,13,13,.4,26,26)
    mars = Body(.11*EM,-1.524*AU,0,0,24140,4,0,1,1,marsi,10,10,.3,20,20)

    listp = [sun,mercury,venus,earth,mars]

    # put em in a list, for safekeeping
    # as of now, the planets are still sleeping
    solar = System(listp)

    # kill the backlights, set up the stage,
    # draw things inside the page
    set_clear_color(0, 0, 0)
    enable_smoothing()
    player = Spaceship(3*WINDOW_HEIGHT/4,3*WINDOW_HEIGHT/4)


    while not window_closed():

        # draw the spaceship yo
        clear()
        player.spaceshipupdate()
        player.draw()


        # Draw the system in its current state.
        solar.draw(WINDOW_WIDTH / 2, WINDOW_HEIGHT / 2, PIXELS_PER_METER)

        # Update the system for its next state.
        solar.update(SEC_PER_FRAME)

        # Draw the frame and take a brief nap.
        request_redraw()
        sleep(TIMESTEP)