Esempio n. 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")
Esempio n. 2
0
 def test_play_soft(self):
     game = Game(resolution=(100, 100))
     game.autoscale = False
     p = PlayerPygletSFX(game)
     p.load("test_data/data/sfx/achievement.ogg", 0.3)
     assert p._sound
     p.play()
     sleep(1.2)
Esempio n. 3
0
    def test_smart(self):
        game = Game(resolution=(100, 100))
        game.autoscale = False
        game.working_directory = "/home/luke/Projects/pyvida/test_data"
        a = Actor("Adam")
        a.smart(game)

        assert list(a.actions.keys()) == ["idle"]
        assert a.resource_name == "Adam"
Esempio n. 4
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()
Esempio n. 5
0
    def test_reset_window(self):
        res = [100, 100]
        game = Game()
        game.autoscale = False
        game.resolution = res
        game._window = MagicMock()
        game._window.get_size.return_value = res

        game.reset_window(fullscreen=False, create=False)

        assert game.fullscreen == False
Esempio n. 6
0
 def test_smart_basic(self):
     game = Game("Test",
                 "1.0",
                 "1.0",
                 "testpyvida",
                 fps=16,
                 afps=16,
                 resolution=(100, 100))
     game.autoscale = False
     game.working_directory = TEST_PATH
     game.immediate_smart()
     assert len(game.items) == 2
     assert len(game.actors) == 4
     assert len(game.scenes) == 1
Esempio n. 7
0
    def test_load_assets(self):
        game = Game(resolution=(100, 100))
        game.autoscale = False
        game.working_directory = "/home/luke/Projects/pyvida/test_data"
        a = Actor("Adam")
        a.smart(game)
        a.load_assets(game)

        resource = get_resource(a.resource_name)
        action = a.get_action()
        assert resource[0] == 249
        assert resource[1] == 341
        assert action.w == 249
        assert action.h == 341
        assert type(resource[2]) == PyvidaSprite
        assert list(a.actions.keys()) == ["idle"]
Esempio n. 8
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
Esempio n. 9
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
Esempio n. 10
0
 def test_init(self):
     game = Game(resolution=(100, 100))
     game.autoscale = False
     p = PlayerPygletSFX(game)
     assert not p._sound
Esempio n. 11
0
    def test_game_init(self):
        g = Game(resolution=(100, 100))
        g.autoscale = False
        g.init()

        assert g.resolution == (100, 100)