I'm making a 2d platformer and i made my first 3 levels and on the 3rd level there is a platform with 2 enemies moving left and right and It is almost impossible to get through because the players hit box is too big. I was wondering how can I make a hitbox where I can change the size of it.
This is how I'm making the hit box:
self.image = self.images_right[self.index]
self.rect = self.image.get_rect()
self.rect.x = x
self.rect.y = y
self.width = self.image.get_width()
self.height = self.image.get_height()
and this is the collide detection:
#check for collisions with enemy
if pygame.sprite.spritecollide(self, virus_group, False):
game_over = -1
#check for collisions with water
if pygame.sprite.spritecollide(self, water_group, False):
game_over = -1
#check for collisions with exit
if pygame.sprite.spritecollide(self, exit_group, False):
game_over = 1
This is how I am seeing the hitbox:
pygame.draw.rect(win, (255, 255, 255), self.rect, 2)
I am new to to coding so I don't know if this is all the code you need to see so if you think it might be something else I can share more code.