Ejemplo n.º 1
0
    def run(self):
        """Execute the game loop
        """
        pygame.init()
        screen = Screen(self.window_size)
        clock = pygame.time.Clock()

        world = World()
        scheduler = Scheduler()

        graphics_system = GraphicsSystem(world, screen)
        load_assets(graphics_system)

        tile_system = TileSystem(world, 5)

        mouse_system = MouseSystem(world)
        animation_system = AnimationSystem(world)

        light_system = LightSystem(world)
        
        fear_system = FearSystem(world)

        clock.tick(self.fps)
        playing = [True]

        def end_game():
            playing[0] = False

        create_title_screen(world, scheduler, end_game)

        while playing[0]:
            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    playing[0] = False
                elif event.type == pygame.MOUSEBUTTONDOWN:
                    mouse_system.on_mouse_down(
                        event.pos,
                        to_mouse_button(event.button)
                    )
                elif event.type == pygame.MOUSEMOTION:
                    mouse_system.on_mouse_motion(event.pos)

            clock.tick(self.fps)
            time_elapsed = float(clock.get_time()) / 1000.0

            scheduler.update(time_elapsed)
            animation_system.update(time_elapsed)
            tile_system.update_tile_positions()
            light_system.update()
            fear_system.update()
            graphics_system.draw_entities()

            pygame.display.set_caption(
                "The Family's Treasure Tale --- " + str(clock.get_fps()))

        pygame.quit()
Ejemplo n.º 2
0
    def run(self):
        """Execute the game loop
        """
        pygame.init()
        screen = Screen(self.window_size)
        clock = pygame.time.Clock()

        world = World()
        scheduler = Scheduler()

        graphics_system = GraphicsSystem(world, screen)
        load_assets(graphics_system)

        tile_system = TileSystem(world, 5)

        mouse_system = MouseSystem(world)
        animation_system = AnimationSystem(world)

        light_system = LightSystem(world)

        fear_system = FearSystem(world)

        clock.tick(self.fps)
        playing = [True]

        def end_game():
            playing[0] = False

        create_title_screen(world, scheduler, end_game)

        while playing[0]:
            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    playing[0] = False
                elif event.type == pygame.MOUSEBUTTONDOWN:
                    mouse_system.on_mouse_down(event.pos,
                                               to_mouse_button(event.button))
                elif event.type == pygame.MOUSEMOTION:
                    mouse_system.on_mouse_motion(event.pos)

            clock.tick(self.fps)
            time_elapsed = float(clock.get_time()) / 1000.0

            scheduler.update(time_elapsed)
            animation_system.update(time_elapsed)
            tile_system.update_tile_positions()
            light_system.update()
            fear_system.update()
            graphics_system.draw_entities()

            pygame.display.set_caption("The Family's Treasure Tale --- " +
                                       str(clock.get_fps()))

        pygame.quit()