Гравитация в pygame

Я пытался реализовать гравитацию для двух тел(один статичный - Blue и один динамичный - Red), чтобы в дальнейшем сделать для трех тел(два статичных и один динамичный), однако в процессе создания у меня возник вопрос: Как составить правильную изначальную инерцию (self.i0), нужное направление движения и скорости у тела Red?

Основной код:

class Static():
    def __init__(self, x, y, mass):
        self.x = x
        self.y = y
        self.mass = mass

class Dynamic():
    def __init__(self, x, y, v, mass):
        self.x = x
        self.y = y
        self.i0 = v
        self.mass = mass
        self.i, self.vy, self.f, self.fy = 0, 0, 0, 0

    def update(self):
        self.f = +(g * Red.mass * Blue.mass) / ((distance(Red.x, Red.y, Blue.x, Blue.y)) ** 2)
        self.i = self.f + 0#self.i0
        self.x += self.i
        #self.y += (self.v + self.f)
        print(self.f, self.i0)

Red = Dynamic(430,515, 1, 50)
Blue = Static(522, 496, 10)
window_size = (992, 992)
c = 16
square_size = window_size[0] // c

И отрисовка:

while True:
    pygame.display.update()
    x_mouse, y_mouse = pygame.mouse.get_pos()
    mouse_pos = [x_mouse, y_mouse]
    # print(mouse_pos)

    target = x_mouse * y_mouse
    pygame.display.flip()
    pygame.display.update()
    Red.update()
    screen.fill('Black')
    pygame.draw.circle(screen, 'red', (Red.x, Red.y), square_size//8)
    pygame.draw.circle(screen, 'blue', (Blue.x, Blue.y), square_size//8)
    pygame.display.update()

    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            pygame.quit()

Ответы (0 шт):