Example #1
0
    def bgen(self, limittime = 60.1): # 1:00
        self.score = {}
        for t in boards.initsubgame(music, self.displaypoints):
            yield t

        self.ready = 0
        self.trons = []
        self.trailsprites = []
        self.playerlist = BubPlayer.PlayerList[:]
        tc = boards.TimeCounter(limittime)
        for t in self.frame(tc):
            t = boards.normal_frame()
            self.build_trons()
            yield t
            tc.update(t)
            if (BubPlayer.FrameCounter & 15) == 7:
                for s in images.ActiveSprites:
                    if isinstance(s, Bubble):
                        s.pop()
                    elif isinstance(s, Bonus):
                        s.kill()

        self.ready = 0
        tc.restore()
        for t in boards.result_ranking(self.score):
            for p in BubPlayer.PlayerList:
                for d in p.dragons[:]:
                    d.kill()
            yield t
        self.remove_trons()
Example #2
0
    def bgen(self, limittime=60.1):  # 0:60
        self.score = {}
        for t in boards.initsubgame(music, self.displaypoints):
            yield t
        self.lemmap = {}
        for key in localmap:
            self.lemmap[key] = images.sprget(key)

        tc = boards.TimeCounter(limittime)
        self.lemlist = []
        self.lemtotal = 0
        for t in self.frame():
            t = boards.normal_frame()
            yield t
            tc.update(t)
            if tc.time == 0.0:
                break

        tc.restore()
        for s in self.lemlist[:]:
            if s.alive:
                s.kill()
        for s in images.ActiveSprites[:]:
            if isinstance(s, Bubble):
                s.pop()
        for t in boards.result_ranking(self.score.copy(), self.lemtotal):
            yield t
Example #3
0
    def bgen(self, limittime=90.1):  # 1:30
        self.score = {}
        for t in boards.initsubgame(music, self.displaypoints):
            yield t

        tc = boards.TimeCounter(limittime)
        for t in self.frame(tc):
            t = boards.normal_frame()
            self.build_planes()
            yield t
            tc.update(t)
            if (BubPlayer.FrameCounter & 15) == 7:
                for s in images.ActiveSprites:
                    if isinstance(s, Bubble):
                        s.pop()
                    elif isinstance(s, Bonus):
                        s.kill()

        tc.restore()
        score = {}
        for player, shotlist in self.score.items():
            score[player] = len(shotlist)
        for t in boards.result_ranking(score):
            for p in BubPlayer.PlayerList:
                for d in p.dragons[:]:
                    d.kill()
            yield t
        self.remove_planes()
Example #4
0
    def bgen(self, limittime=90.1):  # 1:30
        import boards
        from player import BubPlayer

        self.score = {}
        for t in boards.initsubgame(music, self.displaypoints):
            yield t

        tc = boards.TimeCounter(limittime)
        self.ready = 0
        self.staticbricks = {}
        finished = 0
        for t in self.frame():
            t = boards.normal_frame()
            self.build_eyes()
            yield t
            tc.update(t)
            if tc.time == 0.0:
                self.ready = 2
                finished += not self.still_playing()
                if finished > 16:
                    break
            if (BubPlayer.FrameCounter & 15) == 7:
                for s in images.ActiveSprites:
                    if isinstance(s, Bubble):
                        s.pop()
                    elif isinstance(s, Bonus):
                        s.kill()

        tc.restore()
        for t in boards.result_ranking(self.score):
            self.remove_eyes()
            yield t
        for s in self.staticbricks.values():
            s.remove()
Example #5
0
    def bgen(self, limittime=45.1):  # 0:45
        import boards
        from player import BubPlayer

        self.ready = 0
        self.dots = []
        monsters = BubPlayer.MonsterList[:]
        random.shuffle(monsters)
        keep = len([p for p in BubPlayer.PlayerList if p.isplaying()])
        monsters = monsters[:2 + keep // 2]
        for d in monsters:
            PacGhost(self, d.x, d.y)

        for t in boards.initsubgame(music, self.displaypoints):
            yield t

        tc = boards.TimeCounter(limittime)
        self.builddelay = {}
        self.latestposition = {}
        self.pacs = []
        #finish = 0
        for t in self.frame():
            t = boards.normal_frame()
            self.build_pacs()
            yield t
            #if len(self.pacs) == 0:
            #    finish += 1
            #    if finish == 20:
            #        break
            #else:
            #    finish = 0
            tc.update(t)
            if tc.time == 0.0:
                break
            if (BubPlayer.FrameCounter & 15) == 7:
                for s in images.ActiveSprites:
                    if isinstance(s, Bubble):
                        s.pop()

        tc.restore()
        self.ready = 0
        results = {}
        for b in self.dots:
            for d in b.taken_by:
                bubber = d.bubber
                results[bubber] = results.get(bubber, 0) + 1
        for t in boards.result_ranking(results, len(self.dots)):
            self.remove_pacs()
            yield t
        for s in images.ActiveSprites[:]:
            if isinstance(s, Bonus):
                s.kill()
Example #6
0
    def bgen(self, limittime=60.1):  # 0:60
        import boards
        from player import BubPlayer

        self.bricks = {}
        for t in boards.initsubgame(music, self.displaypoints):
            yield t

        tc = boards.TimeCounter(limittime)
        self.ready = 0
        self.builddelay = {}
        self.nbbricks = 0
        self.order = []
        self.paddles = []
        #finish = 0
        for t in self.frame():
            self.order_paddles()
            t = boards.normal_frame()
            self.build_paddles()
            yield t
            #if len(self.paddles) == 0:
            #    finish += 1
            #    if finish == 20:
            #        break
            #else:
            #    finish = 0
            tc.update(t)
            if tc.time == 0.0:
                break
            if (BubPlayer.FrameCounter & 15) == 7:
                for s in images.ActiveSprites:
                    if isinstance(s, Bonus):
                        s.timeout = 0  # bonuses stay
                    elif isinstance(s, Bubble):
                        s.pop()

        tc.restore()
        self.ready = 0
        for s in images.ActiveSprites[:]:
            if isinstance(s, Ball):
                s.pop()
        for t in boards.result_ranking(self.bricks, self.nbbricks):
            self.build_paddles()
            yield t
        self.remove_paddles()
        self.unframe()
Example #7
0
def display(lines, timeleft, bgen=None, black=0):
    waves = []
    if lines:
        totalwidth = 0
        totalheight = 0
        for line in lines:
            w, h = linesize(line)
            if w > totalwidth:
                totalwidth = w
            totalheight += h
        heightmargin = (boards.bheight - 2 * CELL -
                        totalheight) // (len(lines) + 1)
        if heightmargin > VMARGIN:
            heightmargin = VMARGIN
        totalheight += heightmargin * (len(lines) + 1)

        # size in number of CELLs
        cwidth = (totalwidth + CELL - 1) // CELL
        cheight = (totalheight + CELL - 1) // CELL

        x0 = ((boards.width - cwidth) // 2) * CELL + HALFCELL
        y0 = ((boards.height - cheight) // 2) * CELL + HALFCELL
        extras = boards.curboard.sprites.setdefault('ranking', [])
        #while extras:
        #    extras.pop().kill()
        #    yield 0.12
        vspeed = -4
        while extras:
            nextras = []
            for s in extras:
                s.step(0, vspeed)
                if s.y + s.ico.h <= 0:
                    s.kill()
                else:
                    nextras.append(s)
            extras[:] = nextras
            yield 1
            vspeed -= 1

        # draw the box filled with water
        original_y0 = y0
        wallicon = boards.patget((boards.curboard.num, 0, 0), images.KEYCOL)
        if black:
            fillicon = images.sprget('gameoverbkgnd')
            waveicons = [wallicon]
            y0 = boards.bheight + CELL
        else:
            fillicon = images.sprget(Flood.fill)
            waveicons = [images.sprget(n) for n in Flood.waves]
        for y in range(y0 - CELL, y0 + cheight * CELL + CELL, CELL):
            w = gamesrv.Sprite(wallicon, x0 - CELL, y)
            extras.append(w)
        for x in range(x0, x0 + cwidth * CELL, CELL):
            w = gamesrv.Sprite(wallicon, x, y0 + cheight * CELL)
            extras.append(w)
            w = gamesrv.Sprite(waveicons[-1], x, y0 - CELL)
            extras.append(w)
            waves.append(w)
            for y in range(y0, y0 + cheight * CELL, CELL):
                w = gamesrv.Sprite(fillicon, x, y)
                extras.append(w)
        for y in range(y0 - CELL, y0 + cheight * CELL + CELL, CELL):
            w = gamesrv.Sprite(wallicon, x0 + cwidth * CELL, y)
            extras.append(w)

        # draw the individual items inside
        y = y0 + totalheight
        lines.reverse()
        for line in lines:
            linew, lineh = linesize(line)
            x = x0 + MARGIN
            y -= (lineh + heightmargin)
            for item in line:
                w, h = item.getsize()
                extras += item.render(x, y + (lineh - h) // 2)
                x += w

        vspeed = 0
        while y0 > original_y0:
            vspeed = max(vspeed - 1, original_y0 - y0)
            y0 += vspeed
            for s in extras:
                s.step(0, vspeed)
            yield 1

    while timeleft > 0.0:
        if waves:
            ico = waveicons.pop(0)
            waveicons.append(ico)
            for w in waves:
                w.seticon(ico)
        for i in range(2):
            if bgen is None:
                t = boards.normal_frame()
            else:
                try:
                    t = bgen.next()
                except StopIteration:
                    timeleft = 0.0
                    break
            timeleft -= t
            yield t