Exemple #1
0
    def __init__(self):
        self.conf = Configuration("useroptions.conf")
        w, h = self.conf.get('core', 'window_width', 'window_height')
        font_file = self.conf.get('render', 'font_file')
        font = Font(font_file, FONT_GREYSCALE | FONT_TCOD)
        self.window = Window(int(w),
                             int(h),
                             "Prism Break, Pyweek 11: 'Caught' ",
                             font=font,
                             renderer=RENDER_SDL)
        self.window.keyrepeat = (100, 100)
        self.view = Console(int(w), int(h))
        self.input = InputMapper(self)

        self._scene = None
        self.running = False
    def __init__(self):
        self.conf = Configuration("useroptions.conf")
        w, h = self.conf.get('core', 'window_width', 'window_height')
        font_file = self.conf.get('render', 'font_file')
        font = Font(font_file, FONT_GREYSCALE | FONT_TCOD)
        self.window = Window(int(w), int(h), "Prism Break, Pyweek 11: 'Caught' ", font=font, renderer=RENDER_SDL)
        self.window.keyrepeat = (100, 100)
        self.view = Console(int(w), int(h))
        self.input = InputMapper(self)

        self._scene = None
        self.running = False
Exemple #3
0
class Application(object):
    def __init__(self):
        self.conf = Configuration("useroptions.conf")
        w, h = self.conf.get('core', 'window_width', 'window_height')
        font_file = self.conf.get('render', 'font_file')
        font = Font(font_file, FONT_GREYSCALE | FONT_TCOD)
        self.window = Window(int(w),
                             int(h),
                             "Prism Break, Pyweek 11: 'Caught' ",
                             font=font,
                             renderer=RENDER_SDL)
        self.window.keyrepeat = (100, 100)
        self.view = Console(int(w), int(h))
        self.input = InputMapper(self)

        self._scene = None
        self.running = False

    def _get_scene(self):
        return self._scene

    def _set_scene(self, scene):
        if self._scene:
            self._scene.leave()
        scene.enter(self)
        self._scene = scene

    scene = property(_get_scene, _set_scene)

    def check_for_action(self, section):
        return self.input.check_for_action(section)

    def run(self, scene):
        self.running = True
        self.scene = scene
        while self.running and not self.window.is_closed():
            self.window.clear()
            self.scene.draw(self.view, False)
            self.window.blit(self.view)
            #self.window.write("{0}/fps".format(self.window.fps))
            self.window.flush()

            self.scene.update()

        self.window = None
class Application(object):
    
    def __init__(self):
        self.conf = Configuration("useroptions.conf")
        w, h = self.conf.get('core', 'window_width', 'window_height')
        font_file = self.conf.get('render', 'font_file')
        font = Font(font_file, FONT_GREYSCALE | FONT_TCOD)
        self.window = Window(int(w), int(h), "Prism Break, Pyweek 11: 'Caught' ", font=font, renderer=RENDER_SDL)
        self.window.keyrepeat = (100, 100)
        self.view = Console(int(w), int(h))
        self.input = InputMapper(self)

        self._scene = None
        self.running = False

    def _get_scene(self):
        return self._scene

    def _set_scene(self, scene):
        if self._scene:
            self._scene.leave()
        scene.enter(self)
        self._scene = scene
    scene = property(_get_scene, _set_scene)

    def check_for_action(self, section):
        return self.input.check_for_action(section)

    def run(self, scene):
        self.running = True
        self.scene = scene
        while self.running and not self.window.is_closed():
            self.window.clear()
            self.scene.draw(self.view, False)
            self.window.blit(self.view)
            #self.window.write("{0}/fps".format(self.window.fps))
            self.window.flush()

            self.scene.update()

        self.window = None