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()
def die(self): PirateShip.die(self) if random() < 0.2: state.addsilver(self)