[Python] Pygame image not facing the mouse

Discussão em 'Python' iniciado por Stack, Agosto 2, 2025.

  1. Stack

    Stack Membro Participativo

    Here is my rotating code:

    pos = pygame.mouse.get_pos()
    x_dist = pos[0] - self.rect.centerx
    y_dist = -(pos[1] - self.rect.centery)
    self.angle = math.degrees(math.atan2(y_dist, x_dist))
    self.image = pygame.transform.rotate(self.original_image, self.angle)


    Here is my image:

    [​IMG]

    The problem is, when I rotate it, I have to subtract the angle by 90 to get the right result.

    I have searched all over stack overflow but nothing works.

    Continue reading...

Compartilhe esta Página