-
-
Notifications
You must be signed in to change notification settings - Fork 165
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
Add Circle colliderect()
#2560
Conversation
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>
There was a problem hiding this 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()
There was a problem hiding this 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
There was a problem hiding this 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 🎉
This PR adds the Circle.colliderect function. To ease review and test time the Rect/Frect
collidecircle()
function will be added in a future PR.Credits
Geometry Project:
For code, docs and tests:
@novialriptide @Emc2356 @itzpr3d4t0r @ScriptLineStudios @avaxar @Matiiss @newpaxonian @maqa41 @blankRiot96
Also thanks to @Starbuck5 for kickstarting the idea and the occasional help!
Functionality added in this PR
circle.c
https://github.com/pygame-community/pygame-geometry/blame/main/src_c/circle.c
Credits to @Emc2356 @itzpr3d4t0r @novialriptide
geometry.pyi
https://github.com/pygame-community/pygame-geometry/blame/main/geometry.pyi
Credits to @Emc2356 @itzpr3d4t0r @novialriptide @ScriptLineStudios @avaxar
geometry_test.py
https://github.com/pygame-community/pygame-geometry/blame/main/test/test_circle.py
Credits to @itzpr3d4t0r @novialriptide
geometry.rst
https://github.com/pygame-community/pygame-geometry/blame/main/docs/circle.rst
Credits to @itzpr3d4t0r
collisions.c
Credits to @Emc2356 @itzpr3d4t0r @novialriptide @ScriptLineStudios @avaxar
https://github.com/pygame-community/pygame-geometry/blame/main/src_c/collisions.c
collisions.h
@Emc2356 @itzpr3d4t0r @novialriptide
https://github.com/pygame-community/pygame-geometry/blame/main/src_c/include/collisions.h
geometry.h
https://github.com/pygame-community/pygame-geometry/blame/main/src_c/include/geometry.h
Credits to @Emc2356 @itzpr3d4t0r @maqa41