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

Add Circle colliderect() #2560

Merged
merged 6 commits into from
Dec 11, 2023

Conversation

itzpr3d4t0r
Copy link
Member

@itzpr3d4t0r itzpr3d4t0r commented Nov 11, 2023

Co-authored-by: Emc2356 <63981925+emc2356@users.noreply.github.com>
Co-authored-by: NovialRiptide <35881688+novialriptide@users.noreply.github.com>
Co-authored-by: ScriptLineStudios <scriptlinestudios@protonmail.com>
Co-authored-by: Avaxar <44055981+avaxar@users.noreply.github.com>
Co-authored-by: maqa41 <amehebbet41@gmail.com>
@itzpr3d4t0r itzpr3d4t0r requested a review from a team as a code owner November 11, 2023 11:38
@itzpr3d4t0r itzpr3d4t0r added New API This pull request may need extra debate as it adds a new class or function to pygame geometry pygame.geometry labels Nov 11, 2023
@itzpr3d4t0r itzpr3d4t0r changed the title Add Circlecolliderect() Add Circle colliderect() Nov 11, 2023
@itzpr3d4t0r itzpr3d4t0r mentioned this pull request Nov 11, 2023
87 tasks
Copy link
Member

@MyreMylar MyreMylar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

Code looks fine, works locally in my testing program, tests pass locally too. Works on CI.

Test program:

import pygame

from pygame import Color, Rect
from pygame.geometry import Circle

pygame.init()
screen = pygame.display.set_mode((640, 480), 0)

white_background = pygame.Surface(screen.get_rect().size)
white_background.fill((255, 255, 255))

circle_1 = Circle((50, 50), 30)
circle_col = Color("red")

rect_1 = Rect((100, 100), (250, 300))
rect_1_col = Color("blue")

running = True

while running:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            running = False

    circle_1.center = pygame.mouse.get_pos()

    if circle_1.colliderect(rect_1):
        circle_col = Color("blue")
        rect_1_col = Color("green")
    else:
        circle_col = Color("red")
        rect_1_col = Color("blue")

    screen.blit(white_background, (0, 0))

    pygame.draw.circle(screen, circle_col, (circle_1.x, circle_1.y), circle_1.r)
    pygame.draw.rect(screen, rect_1_col, rect_1)

    pygame.display.flip()


pygame.quit()

buildconfig/stubs/pygame/geometry.pyi Outdated Show resolved Hide resolved
src_c/circle.c Show resolved Hide resolved
src_c/collisions.c Show resolved Hide resolved
Copy link
Member

@ankith26 ankith26 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PRs got conflicts now

Copy link
Member

@ankith26 ankith26 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for the PR 🎉

@ankith26 ankith26 merged commit da52aab into pygame-community:main Dec 11, 2023
29 of 30 checks passed
@itzpr3d4t0r itzpr3d4t0r added this to the 2.4.0 milestone Dec 11, 2023
@itzpr3d4t0r itzpr3d4t0r deleted the circle-colliderect branch December 11, 2023 18:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
geometry pygame.geometry New API This pull request may need extra debate as it adds a new class or function to pygame
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants