Mar-19-2019, 05:45 PM
BoatSprite class add health variable.
self.health = 3For your groups you can have on for boat enemies.
self.bullet_group = pygame.sprite.Group() self.pirate_group = pygame.sprite.Group() self.croc_group = pygame.sprite.Group()Can be replace by.
self.boat_enemies_group = pygame.sprite.Group()Then boat losing a life. Check all objects in the list. Returns all objects that boat collided with.
# Colliding hit = pygame.sprite.spritecollide(self.boat, self.boat_enemies_group, False) if len(hit) > 0: self.boat.health -= 1 if self.boat.health == 0: # boat diesAll your draw code for the scene should be under draw method.
self.surface.blit(self.heart, (600, 20)) self.surface.blit(self.heart, (600, 50)) self.surface.blit(self.heart, (600, 80))
99 percent of computer problems exists between chair and keyboard.