当前位置: 首页>>代码示例>>Python>>正文


Python Channel.start方法代码示例

本文整理汇总了Python中channel.Channel.start方法的典型用法代码示例。如果您正苦于以下问题:Python Channel.start方法的具体用法?Python Channel.start怎么用?Python Channel.start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在channel.Channel的用法示例。


在下文中一共展示了Channel.start方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Game

# 需要导入模块: from channel import Channel [as 别名]
# 或者: from channel.Channel import start [as 别名]

#.........这里部分代码省略.........
        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")
    def custom_action(self):
        if not sys.stdout.isatty():
            self.error("Error: Not run from tty")
        elif self.window.fullscreen:
            self.error("Error: Can't access from fullscreen")
        else:
            action = raw_input("Enter action:\n>>>")
            exec(action)
            return 0
    def play_sound(self, path):
        sound = pygame.mixer.Sound(path)
        sound.play()
    def run(self):
        self.load_run("menus/logo.gsl")
        self.channel.start()
        self.load_run("menus/main_menu.gsl")
开发者ID:m-nez,项目名称:gravity_slingshot,代码行数:104,代码来源:game_class.py


注:本文中的channel.Channel.start方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。