def __init__(self, name, resolution, resources_folder, fps=FRAMES_PER_SECOND): super(Game, self).__init__() ResourceLoader().set_resources_folder(resources_folder) pygame.init() self._window = pygame.display.set_mode(resolution) Widget.set_resolution(resolution) pygame.display.set_caption(name) self._frames_delta = 1.0 / fps self._navigator = Navigator()
def __init__(self): super(EndGame, self).__init__() self.add_layer( Layer(position=(0, 0), size=Widget.get_resolution()).fill('191919'), 0 ) self._interface = Interface('interfaces.endgame') self.add_layer(self._interface, 100) self.listen_key('return')
def __init__(self, path): super(Interface, self).__init__( position=(0, 0), size=Widget.get_resolution() ) self.set_transparent(True) self._dom = ResourceLoader().get_raw_resource(path) self._index = 0 self._ids = {} self._root = self._dom.getElementsByTagName('interface')[0] for node in self._root.childNodes: self._build_node(node, None)
def __init__(self, level, image_id): super(ComicStrip, self).__init__() self.add_layer( Layer(position=(0, 0), size=Widget.get_resolution()).fill('ffffff'), 0 ) (res_width,res_height) = Widget.get_resolution() self._res_width = res_width self._res_height = res_height self._level = level self._interface = Interface('interfaces.comicstrip') self._height = self.loader().get_raw_resource(image_id).get_height() self._increment = 100 self._interface.get('comicstrip').style('background-image', image_id) self.add_layer(self._interface, 100) self.listen_key('return') self.listen_key('down') self.listen_key('up')
def __init__(self): super(MainMenu, self).__init__() self.add_layer( Layer(position=(0, 0), size=Widget.get_resolution()).fill('191919'), 0 ) self._interface = Interface('interfaces.mainmenu') JukeBox().play('music.intro') self.add_layer(self._interface, 100) self._choice = 0 self._up_tap = False self._down_tap = False self.listen('quit') self.listen_key('up') self.listen_key('down') self.listen_key('return')
def __init__(self): super(LoadingScreen, self).__init__() self.loader().load_package('loading') self.loader().load_package('interfaces') resolution = Widget.get_resolution() res_width, res_height = resolution self.add_layer( Layer(position=(0, 0), size=resolution).fill('191919'), 0 ) self._animation = AnimatedLayer( position=(res_width / 2 - 120, res_height / 2.3), size=(275, 50) ) self._animation.set_animation('loading.tinyrat.walk') self.add_layer(self._animation, 1) self.listen('quit') self._interface = Interface('interfaces.loadingscreen') self.add_layer(self._interface, 100) self._queue = Queue.Queue() self._loading_task = LoadingTask(self.loader(), self._queue) self._loading_task.start()
def play(self): self._navigator.set_current_view( ComicStrip(Lab1(Widget.get_resolution(), self._navigator), 'static.comic_strip_1') )