Skip to content

Commit

Permalink
Better way of having health bars follow players
Browse files Browse the repository at this point in the history
  • Loading branch information
Parker8283 committed Apr 15, 2024
1 parent 28fb2a9 commit 36b44ce
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/sprites.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def update(self, screen_rect, group, delta_time):
self.__set_surf()
self.move_nearest_ip(group)
self.rect.clamp_ip(screen_rect)
self.health_bar_rect.clamp_ip(screen_rect)
self.health_bar_rect = self.health_bar_bg.get_rect(topleft=self.rect.move(0, -10).topleft)
self.do_attack(group)

def draw(self, screen):
Expand Down Expand Up @@ -138,7 +138,6 @@ def move_nearest_ip(self, group: Group):
vec = dist.normalize() * self.speed
if not pygame.sprite.spritecollideany(self, group, self.__collided):
self.rect.move_ip(vec)
self.health_bar_rect.move_ip(vec)
self.walking = True
return
self.walking = False
Expand Down

0 comments on commit 36b44ce

Please sign in to comment.