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")
def test_get_best_file(self, use_game, working_dir, fname, expected): # '../../../../../Projects/pyvida/test_data/data/actors/Adam/idle.montage' game = Game() if use_game else None if game: game.working_directory = working_dir f = get_best_file(game, fname) assert expected in f
def test_layers_game(self): game = Game() game.working_directory = "/home/luke/Projects/pyvida/test_data" s = Scene("testscene") game.immediate_add(s) s._load_layer("scenes/title/background.png") assert len(s.layers) == 1 assert list(game.items.keys()) == ["testscene_background"]
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"
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
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"]
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
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