Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix line rotate #238

Merged
merged 2 commits into from
Oct 19, 2024
Merged

Fix line rotate #238

merged 2 commits into from
Oct 19, 2024

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.

1 participant