0

I've been following a tutorial on youtube about pygame and in the tutorial, he writes a code for a hitbox. The hitbox is based on the image of the sprite. My image is bigger than the actual populated area for the sprite.

The code I use for the rect is this:

self.rect = pygame.Rect(playerSprite.get_rect().left, playerSprite.get_rect().top, 100, playerSprite.get_rect().height)

and the draw method is this:

    def draw(self):
    screen.blit(pygame.transform.flip(self.playerSprite, self.flip, False), self.rect)  
    pygame.draw.rect(screen, black, self.rect, width=1) 

How do I offset the hitbox?

This is what the hitbox currently looks like

0 Answers0