def exit_board(delay=8, music=None, repeatmusic=[]): from bubbles import Bubble from bonuses import RandomBonus, end_normal_play from player import BubPlayer from monsters import Monster end_normal_play() curboard.playingboard = 0 actives = images.ActiveSprites[:] for s in actives: if ((isinstance(s, Monster) and s.still_playing()) or isinstance(s, RandomBonus)): s.kill() music = music or [] if BubPlayer.MegaBonus: music[:1] = [images.music_modern] if music or repeatmusic: gamesrv.set_musics(music, repeatmusic) for i in range(delay): yield normal_frame() bubble_outcome = BubPlayer.BubblesBecome or Bubble.pop for s in actives: if isinstance(s, Bubble): bubble_outcome(s) yield normal_frame() if BubPlayer.MegaBonus: BubPlayer.MegaBonus()
def game_over(): yield force_singlegen() from player import scoreboard import ranking images.Snd.Extralife.play() gamesrv.set_musics([], [images.music_potion]) scoreboard() for t in ranking.game_over(): yield t
def result_ranking(results, maximum=None, timeleft=200): import ranking results = ranking.ranking_picture(results, maximum, timeleft is not None) if curboard.bonuslevel and timeleft is not None: play_again = bonus_play() else: play_again = None for t in ranking.display(results, timeleft, play_again): yield t if gamesrv.game.End != 'gameover': gamesrv.set_musics([], []) replace_boardgen(next_board(), 1)
def normal_play(): from player import BubPlayer import bonuses framecounter = 0 bonus_callback = bonuses.start_normal_play() while BubPlayer.MonsterList: bonus_callback() yield normal_frame() if not BubPlayer.DragonList: continue framecounter += 1 BASE = 500 if not (framecounter % BASE): if framecounter == 4*BASE: from monsters import Monster from mnstrmap import BigImages ico = images.sprget(BigImages.hurryup[1]) s = images.ActiveSprite(ico, (bwidth-ico.w)//2, (bheight-ico.h)//2) s.setimages(s.die(BigImages.hurryup * 12, 2)) images.Snd.Hurry.play() mlist = [s for s in images.ActiveSprites if (isinstance(s, Monster) and s.regular() and not s.angry)] if mlist: s = random.choice(mlist) s.angry = [s.genangry()] s.resetimages() if framecounter >= 6*BASE: mlist = [s for s in images.ActiveSprites if isinstance(s, Monster) and s.regular() and s.angry] if mlist: images.Snd.Hell.play() gamesrv.set_musics([], []) s = random.choice(mlist) s.become_ghost() framecounter = -200 else: framecounter = 2*BASE if framecounter == 0: curboard.set_musics() replace_boardgen(last_monster_killed(), 1)
def set_musics(self, prefix=[]): if (self.num+1) % 20 < 10: gamesrv.set_musics(prefix + [images.music_intro], [images.music_game], reset=0) else: gamesrv.set_musics(prefix + [], [images.music_game2], reset=0)
def wait_for_one_player(): from player import BubPlayer clearallsprites() nimages = None while not [p for p in BubPlayer.PlayerList if p.isplaying()]: yield 3 if not nimages: desc = getattr(gamesrv.game, 'FnDesc', '?') host, port = getattr(gamesrv.game, 'address', ('?', '?')) images.writestrlines([ "Welcome to", desc.upper(), "at %s:%s" % (host.lower(), port), None, "Click on your Favorite Color's Dragon", "Choose four keys: Right, Left, Jump, Shoot", "and Let's Go!", None, "Click again for more than one player", "on the same machine.", ]) from mnstrmap import PlayerBubbles nimages = [PlayerBubbles.bubble[0], PlayerBubbles.bubble[1], PlayerBubbles.bubble[1], PlayerBubbles.bubble[0], PlayerBubbles.bubble[2], PlayerBubbles.bubble[2]] screenwidth = bwidth + 9*CELL screenheight = bheight def welcomebubbling(self): fx = self.x dx = (random.random() - 0.5) * 1.9 for y in range(self.y-3, -self.ico.h, -3): fx += dx self.move(int(fx), y) yield None if y == self.ypop: from mnstrmap import PlayerBubbles self.setimages(None) self.gen.append(self.die(PlayerBubbles.explosion)) self.kill() yield 10 gamesrv.set_musics([], [images.music_game2], reset=0) if ((not images.ActiveSprites or random.random() < 0.05678) and gamesrv.clients): # make sure the extension's images are loaded too # NB. this is also needed for import auto-detection import ext1; import ext2; import ext3 import ext4; import ext5; import ext6 import ext7 ico = images.sprget(nimages[0]) s = images.ActiveSprite(ico, random.randrange(0, screenwidth-ico.w), screenheight) s.ypop = random.randrange(-ico.h, screenheight) s.gen = [welcomebubbling(s)] s.setimages(s.cyclic(nimages, speed=1)) if random.random() > 0.4321: try: key, (filename, (x, y, w, h)) = random.choice( images.sprmap.items()) except: w = h = 0 if w == h == 32: s2 = images.ActiveSprite(images.sprget(key), -32, 0) s2.gen = [s2.following(s, (s.ico.w-32)//2, (s.ico.h-32)//2)] s.ypop = None images.action(images.ActiveSprites[:])