def to_front(self): ActiveSprite.to_front(self) if self.dcap['overlayglasses']: ico = images.sprget(('glasses', self.dir)) y = self.y + self.overlayyoffset if self.overlaysprite is None or not self.overlaysprite.alive: self.overlaysprite = images.ActiveSprite(ico, self.x, y) else: self.overlaysprite.to_front() self.overlaysprite.move(self.x, y, ico) self.overlaysprite.gen = [self.overlaysprite.die([None])]
def to_front(self): if self.gen: ActiveSprite.to_front(self)
class Pac(PacSprite): no_hat = 1 def __init__(self, pacman, bubber, x, y, dcap): ico = GreenAndBlue.normal_bubbles[bubber.pn][1] PacSprite.__init__(self, images.sprget(('eyes', 0, 0)), x, y) self.bubble = ActiveSprite(images.sprget(ico), x, y) self.bubber = bubber self.pacman = pacman self.ready = 0 self.gen.append(self.playing()) self.pacman.pacs.append(self) self.dcap = dcap def resetimages(self, dx, dy): self.ready = 1 self.setimages( self.cyclic([('pac-lg', dx, dy), 'pac-black', ('pac-sm', dx, dy)], 5)) def to_front(self): self.bubble.to_front() ActiveSprite.to_front(self) def kill(self): self.play(images.Snd.Pop) self.bubble.gen = [self.bubble.die(Bubble.exploding_bubbles)] self.pacman.latestposition[self.bubber] = self.x, self.y try: self.bubber.dragons.remove(self) except ValueError: pass try: self.pacman.pacs.remove(self) except ValueError: pass ActiveSprite.kill(self) def playing(self): bubber = self.bubber for t in self.moving(): if self.pacman.ready: d = [(bubber.key_left, -1, 0), (bubber.key_right, 1, 0), (bubber.key_jump, 0, -1), (bubber.key_fire, 0, 1)] d.sort() if d[-1][0] > d[-2][0]: self.wannadx, self.wannady = d[-1][1:] self.bubble.move(self.x, self.y) yield None if self.ready: touching = images.touching(self.x + CELL - 3, self.y + CELL - 3, 6, 6) touching.reverse() for s in touching: if isinstance(s, Bonus): s.touched(self) elif isinstance(s, PacGhost): self.kill() return
def to_front(self): self.bubble.to_front() ActiveSprite.to_front(self)