| 175 | self.attack_cooldown = 20 |
| 176 | |
| 177 | def attack(self, target): |
| 178 | if self.attack_cooldown == 0: |
| 179 | # execute attack |
| 180 | self.attacking = True |
| 181 | self.attack_sound.play() |
| 182 | attacking_rect = pygame.Rect( |
| 183 | self.rect.centerx - (2 * self.rect.width * self.flip), |
| 184 | self.rect.y, |
| 185 | 2 * self.rect.width, |
| 186 | self.rect.height, |
| 187 | ) |
| 188 | if attacking_rect.colliderect(target.rect): |
| 189 | target.health -= 10 |
| 190 | target.hit = True |
| 191 | |
| 192 | def update_action(self, new_action): |
| 193 | # check if the new action is different to the previous one |