-1

So I'm making a little archery game for school. To check collision between the arrow and the targets I use the pygame.sprite.spritecollide() function, and the sprites are masked. This is the arrow's code to check collision: python def check_collisions(self, targets, glob_score):

    hits = pygame.sprite.spritecollide(self, targets, True, pygame.sprite.collide_mask)
    for i in hits:
        i.on_hit(glob_score)
    
    if hits:
        self.destroy()

Where targets is the pygame.sprite.Group containing the targets. The thing is: sometimes it works and sometimes the arrow goes right trough the target. Bug To make the mask I use the pygame.mask.from_surface() and the sprites are .png files with a transparent background

0

0

Browse other questions tagged or ask your own question.