本文整理汇总了Python中channel.Channel.set_volume方法的典型用法代码示例。如果您正苦于以下问题:Python Channel.set_volume方法的具体用法?Python Channel.set_volume怎么用?Python Channel.set_volume使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类channel.Channel
的用法示例。
在下文中一共展示了Channel.set_volume方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Game
# 需要导入模块: from channel import Channel [as 别名]
# 或者: from channel.Channel import set_volume [as 别名]
class Game(Scene):
def __init__(self):
self.window = Window()
self.channel=Channel("music/loop")
self.load_display()
self.images = {}
self.running = False
self.add_image_dir("images")
self.levels = listdir("levels")
self.levels = [level for level in self.levels if level[0] !='.']
self.level_info =["N/A", "N/A", "N/A"]
self.level_index = 0
self.level_outcome = None
fill_save_dir()
self.saves = listdir("saves")
self.saves = [save for save in self.saves if save[0] != '.']
self.saves = proper_sort(self.saves)
self.current_scenes = []
self.current_song = -1
self.error_message=""
if self.saves != []:
self.level_info = load_save(self.saves[self.level_index])
def save_display(self, size = None, fullscreen = None, fps = None):
if size == None:
size = self.window.modes[self.window.mode_index]
if fullscreen == None:
fullscreen=self.window.fullscreen
if fps == None:
fps = self.window.fps
if not "display.cfg" in listdir("config"):
size = pygame.display.list_modes()[-1]
fullscreen = False
disp = open("config/display.cfg", 'w')
disp.write("%r\n%r\n%r\n%r" % (size, fullscreen, fps, self.channel.get_volume()) )
disp.close()
def load_display(self):
if not "display.cfg" in listdir("config"):
self.save_display()
disp = open("config/display.cfg")
self.window.size = eval(disp.readline().strip())
self.window.fullscreen = eval(disp.readline().strip())
self.window.fps = eval(disp.readline().strip())
self.channel.set_volume(eval(disp.readline().strip()))
disp.close()
def add_to_game(self, level):
loaded_level = load_level(level)
loaded_level.game = self
loaded_level.window = self.window
return loaded_level
def redraw_all_scenes(self):
for scene in self.current_scenes:
for layer in scene.render_layers:
for obj in layer:
obj.scale_images()
def run_scene(self, scene):
if scene != None:
scene.run()
def load_run(self, level):
scene = self.add_to_game(level)
self.current_scenes.append(scene)
scene.run()
self.current_scenes.remove(scene)
self.redraw_all_scenes()
def change_level(self, amount):
self.level_index = (self.level_index+amount)%len(self.levels)
self.level_info = load_save(self.saves[self.level_index])
for scene in self.current_scenes:
scene.generate_text()
self.redraw_all_scenes()
def play_level(self):
level_name = self.saves[self.level_index][:self.saves[self.level_index].find(".")]
if level_name+"_brief.gsl" in listdir("briefing"):
brief = self.add_to_game("briefing/"+level_name+"_brief.gsl")
brief.run()
level = self.add_to_game("levels/"+self.saves[self.level_index][:self.saves[self.level_index].find(".")]+".gsl")
self.current_scenes.append(level)
outcome = level.run()
self.current_scenes.remove(level)
if self.level_info[2] != "Success":
if outcome[0] == 2:
self.level_info[2] = "Fail"
elif outcome[0] == 1:
self.level_info[2] = "Success"
else:
self.level_info[2] = "Abandon"
self.level_info[1] = str(outcome[1])
elif self.level_info[2] == "Success":
if eval(self.level_info[1]) > outcome[1]:
self.level_info[1] = str(outcome[1])
overwrite_save(self.saves[self.level_index],self.level_info)
if outcome[0] == 2:
self.load_run("menus/fail.gsl")
elif outcome[0] == 1:
self.load_run("menus/success.gsl")
self.redraw_all_scenes()
def error(self, text=None):
if text != None:
self.error_message=text
self.load_run("menus/error.gsl")
#.........这里部分代码省略.........