def hurt(self, dhp=1): self.hp -= dhp self.flashtime = self.tflash if self.hp <= 0: self.die() else: sound.playsound("hurt") if self.smokes: state.addsmoke(self, self.smokes)
def hitany(self, objs): for h in objs: if not h.alive: continue if h.z > self.r: continue dx, dy = h.x - self.x, h.y - self.y if dx ** 2 + dy ** 2 < (self.r + h.r) ** 2: self.alive = False state.addsmoke(self, self.smokes) state.addsilver(self) h.causedamage()