예제 #1
0
    elif (phase == 2):
        if launch_prepped == False:
            # sets the spaceship's position to be equal to earth, but with diff major axis and ecc
            spaceship.r = bodies[0].r
            spaceship.initial_angle = bodies[0].angle
            spaceship.angle = 0
            spaceship.velocity = math.sqrt(
                G * sun_mass * (2 / spaceship.r - 1 / spaceship.a))  #+ 11500
            spaceship.a, spaceship.eccentricity = bodies[
                0].get_transfer_ellipse(bodies[1])
            delta_v = spaceship.velocity - math.sqrt(
                G * sun_mass / spaceship.r)
            spaceship.energy = bodies[0].energy
            spaceship.energy += delta_v**2 / 2
            spaceship.areal_v *= 1.1  # ((G*G*sun_mass*sun_mass*(spaceship.eccentricity**2 - 1))/(8*spaceship.energy))**0.5
            spaceship.colour = (210, 210, 210)
            spaceship.q = spaceship.a * (1 - spaceship.eccentricity**2)
            launch_prepped = True

            spaceship_surface.set_colorkey((0, 0, 0))
            pygame.draw.circle(
                spaceship_surface, spaceship.colour,
                pxs(body_scale * spaceship.body_radius,
                    body_scale * spaceship.body_radius),
                px(body_scale * spaceship.body_radius))
            spaceship_surface = spaceship_surface.convert()
            px_x, px_y = convert_coords(
                math.cos(
                    math.radians(spaceship.angle + spaceship.initial_angle)) *
                spaceship.r,
                math.sin(
예제 #2
0
            phase = 2
            print ("Launching!")

    elif(phase == 2):
        if launch_prepped == False:
            # sets the spaceship's position to be equal to earth, but with diff major axis and ecc
            spaceship.r = bodies[0].r
            spaceship.initial_angle = bodies[0].angle
            spaceship.angle = 0
            spaceship.velocity = math.sqrt(G*sun_mass*(2/spaceship.r - 1/spaceship.a))
            spaceship.a, spaceship.eccentricity = bodies[0].get_transfer_ellipse(bodies[1])
            delta_v = spaceship.velocity - math.sqrt(G*sun_mass/spaceship.r)
            spaceship.energy = bodies[0].energy
            spaceship.energy += delta_v**2/2
            spaceship.areal_v *= 1.08 #((G*G*sun_mass*sun_mass*(spaceship.eccentricity**2 - 1))/(8*spaceship.energy))**0.5
            spaceship.colour = (183,183,183)
            spaceship.q = spaceship.a*(1 - spaceship.eccentricity**2)
            launch_prepped = True

            spaceship_surface.set_colorkey((0,0,0))
            pygame.draw.circle(spaceship_surface, spaceship.colour, pxs(body_scale*spaceship.body_radius, body_scale*spaceship.body_radius), px(body_scale*spaceship.body_radius))
            spaceship_surface = spaceship_surface.convert()
            px_x, px_y = convert_coords(math.cos(math.radians(spaceship.angle + spaceship.initial_angle))*spaceship.r, math.sin(math.radians(spaceship.angle + spaceship.initial_angle))*spaceship.r)
            screen.blit(spaceship_surface, (px_x-px(body_scale*spaceship.body_radius), px_y-px(body_scale*spaceship.body_radius)))
        else:
            spaceship_surface.set_colorkey((0,0,0))
            pygame.draw.circle(spaceship_surface, spaceship.colour, pxs(body_scale*spaceship.body_radius, body_scale*spaceship.body_radius), px(body_scale*spaceship.body_radius))
            spaceship_surface = spaceship_surface.convert()
            centered_coords = spaceship.spaceship_update(ms*secs_per_msecs)
            px_x, px_y = convert_coords(*centered_coords)
            screen.blit(spaceship_surface, (px_x-px(body_scale*spaceship.body_radius), px_y-px(body_scale*spaceship.body_radius)))