Пример #1
0
    def test_scene_with_menu(self):
        game = Game("Test",
                    "1.0",
                    "1.0",
                    "testpyvida",
                    fps=16,
                    afps=16,
                    resolution=(1680, 1050))
        game.autoscale = False
        game.working_directory = "/home/luke/Projects/pyvida/test_data"
        mx, my = game.resolution[0] / 2 - 100, 140  # game.resolution[1]-50
        game.add(MenuFactory("menu", (mx, my)))

        game.immediate_menu_from_factory("menu", [
            ("menu_new", MagicMock()),
            ("menu_old", MagicMock()),
        ])

        game.init()
        game.smart()
        game.queue_load_state("title", "initial")
        game.camera.scene("title")
        game.set_menu(*["menu_new", "menu_old"], clear=True)
        game.menu.show()

        game.update()  # run events

        assert game.w == 1680
        assert not game.autoscale
        assert game.scene == game.scenes["title"]
        assert game.scene.layers[0] == "title_background"
        assert game.scene.get_object("logo")
Пример #2
0
 def test_play_loop(self):
     game = Game(resolution=(100, 100))
     game.autoscale = False
     game.init()
     p = PlayerPygletMusic(game)
     p.load("test_data/data/music/dos4gw_newwake.ogg")
     assert p._music
     p.play(loops=1)
     while p.busy():
         pyglet.clock.tick()
         pyglet.app.platform_event_loop.dispatch_posted_events()
Пример #3
0
def create_basic_scene(resolution=(1680, 1050), with_update=False):
    game = Game("Test",
                "1.0",
                "1.0",
                "testpyvida",
                fps=16,
                afps=16,
                resolution=resolution)
    game.autoscale = False
    game.working_directory = "/home/luke/Projects/pyvida/test_data"
    game.init()
    game.smart()
    game.queue_load_state("title", "initial")
    game.camera.scene("title")
    if with_update:
        game.update()  # perform all the queued events
    return game
Пример #4
0
    def test_scene_with_item(self):
        game = Game("Test",
                    "1.0",
                    "1.0",
                    "testpyvida",
                    fps=16,
                    afps=16,
                    resolution=(1680, 1050))
        game.autoscale = False
        game.working_directory = "/home/luke/Projects/pyvida/test_data"
        game.init()
        game.smart()
        game.queue_load_state("title", "initial")
        game.camera.scene("title")

        game.update()  # run events

        logo = game.scene.get_object("logo")
        assert game.w == 1680
        assert not game.autoscale
        assert game.scene == game.scenes["title"]
        assert game.scene.layers[0] == "title_background"
        assert logo
Пример #5
0
    def test_game_init(self):
        g = Game(resolution=(100, 100))
        g.autoscale = False
        g.init()

        assert g.resolution == (100, 100)