How would I create a rectangle that is smaller than the image? As far as I know, the only way to create a rect around the image is by using:
self.rect = self.image.get_rect()
But that creates a rect that is larger than the image. Thanks.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
A “Rectangle” in a Pygame is a simple object to pass coordinates on surfaces between functions and methods. There is the
pygame.rect.Rectclass, to which you pass (x, y, width, height) to instantiate. Aside from that specific class, almost all functions in pygame that require a rectangle, will also accept an ordinary tuple of (x,y, width, height) – including collision verifications.