本文整理汇总了Python中music.Music.play_bgm方法的典型用法代码示例。如果您正苦于以下问题:Python Music.play_bgm方法的具体用法?Python Music.play_bgm怎么用?Python Music.play_bgm使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类music.Music
的用法示例。
在下文中一共展示了Music.play_bgm方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run_game
# 需要导入模块: from music import Music [as 别名]
# 或者: from music.Music import play_bgm [as 别名]
def run_game():
pygame.init()
ai_setting = Settings()
screen = pygame.display.set_mode((ai_setting.screen_width, ai_setting.screen_height))
pygame.display.set_caption("Alien Invasion")
ship = Ship(ai_setting, screen)
bullets = Group()
aliens = Group()
stats = GameStats(ai_setting)
sb = Scoreboard(ai_setting, screen, stats)
gf.create_fleet(ai_setting, screen, ship, aliens)
play_button = Button(ai_setting, screen, "Play")
music = Music()
while True:
gf.check_events(ai_setting, screen, stats, sb, play_button, ship, aliens, bullets, music)
if stats.game_active:
music.play_bgm()
ship.update()
gf.update_bullets(ai_setting, screen, stats, sb, ship, aliens, bullets, music)
gf.update_aliens(ai_setting, screen, stats, sb, ship, aliens, bullets)
gf.update_screen(ai_setting, screen, stats, sb, ship, aliens, bullets, play_button)