Skip to content

Conversation

@itzpr3d4t0r
Copy link
Member

@itzpr3d4t0r itzpr3d4t0r commented Oct 19, 2024

from geometry import Line
import pygame


def main():
    pygame.init()

    line = Line((100, 100), (700, 700))

    screen = pygame.display.set_mode((800, 800))
    clock = pygame.time.Clock()

    keep = True
    clicked = False

    rot_point = line.center

    while keep:
        dt = clock.tick_busy_loop(60)

        if clicked:
            line.rotate_ip(dt, rot_point)

        screen.fill((0, 0, 0))

        pygame.draw.line(screen, (255, 255, 255), line.a, line.b)
        pygame.draw.circle(screen, (255, 0, 0), rot_point, 5)

        pygame.display.flip()

        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                keep = False
            elif event.type == pygame.MOUSEBUTTONDOWN:
                clicked = True
            elif event.type == pygame.MOUSEBUTTONUP:
                clicked = False
                if event.button == 3:
                    rot_point = event.pos



if __name__ == "__main__":
    main()

@itzpr3d4t0r itzpr3d4t0r merged commit 3c11f8e into main Oct 19, 2024
33 checks passed
@itzpr3d4t0r itzpr3d4t0r deleted the fix_line_rotate branch October 19, 2024 12:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants