def correlation_data(): start_bird_y = randint(-199, 199) rand_density = randint(1, 9) obstacle_diameter = randint(10, 50) obstacle_speed = -randint(1, 5) fall_speed = -randint(10, 30) proximity = randint(2, 30) flappy_game = Game(200, -200, fall_speed, 30, obstacle_diameter, 1, rand_density, obstacle_speed, 0, start_bird_y, proximity, True) flappy_game.game_main_loop()
def test_game_attributes(self): console = Console() player = Player("TestPlayer") game = Game(name="TestGame", console=console, player=player) self.assertEqual(game.name, "TestGame") self.assertEqual(game.console, console) self.assertEqual(game.player, player) self.assertEqual(game.exceptions, []) self.assertEqual(game.actions, []) self.assertEqual(game.running, False) self.assertEqual(game.stopped, False)
def test_started_after_stopped(self): game = Game(name="TestGame", console=Console(), player=Player("TestPlayer")) with self.assertRaises(GameStoppedException): game.stop() game.start(running_mode='test')
def main(player_x, player_y, max_turns, map_file, map_width, map_height, fps, box_density, chopp_density, laptop_density, room_width, room_height, room_box_density, room_chopp_density, room_laptop_density, rooms, drunk_factor, nerd_factor, dance_frames): if not map_file: map_ = build_map(map_width, map_height, room_width, room_height, box_density=box_density, chopp_density=chopp_density, laptop_density=laptop_density, room_box_density=room_box_density, room_chopp_density=room_chopp_density, room_laptop_density=room_laptop_density, rooms=rooms) add_things_randomly( map_, { PLAYER_X: 1, PLAYER_Y: 1, }, ) game = Game( players={ PLAYER_X: get_bot(player_x, PLAYER_X, player_y, map_), PLAYER_Y: get_bot(player_y, PLAYER_Y, player_x, map_), }, max_turns=max_turns, map_=map_, visualizer=MapVisualizer(map_, fps=fps, dance_frames=dance_frames), drunk_factor=drunk_factor, nerd_factor=nerd_factor, ) game.play()
def test_console_none(self): with self.assertRaises(TypeError): Game(name="TestGame", console=None, player=Player("TestPlayer"))
from game.core import Game if __name__ == '__main__': flappy_game = Game(200, -200, -5, 30, 20, 50, 1, -3, 0, 0, 5) flappy_game.main_looop()
def test_started(self): game = Game(name="TestGame", console=Console(), player=Player("TestPlayer")) game.start(running_mode='test') self.assertEqual(game.running, True)
from game.console import Console from game.core import Game, Player console = Console() player = Player("TestPlayer") game = Game(name="TestGame", console=console, player=player) game.start()
def test_player_none(self): with self.assertRaises(TypeError): Game(name="TestGame", console=Console(), player=None)
from game.core import Game if __name__ == "__main__": game = Game(7, 7) game.set_entity(6, 5) game.set_entity(4, 6) game.set_entity(5, 6) game.set_entity(5, 5) game.set_entity(6, 4) game.set_entity(3, 2) game.set_entity(0, 3) game.set_entity(2, 4) game.print_map() for _ in range(20): game.map = game.calculate_next_state() game.print_map()
def main(): signal.signal(signal.SIGINT, signal_handler) resourceManager.init('assets/', imgs) config = Config('config.json') gui.loadSkin(config.skin) game = Game(config) game.init() game.addScene("main", MainMenu(game)) game.addScene("play", Playground(game)) game.addScene("edit", Editor(game)) game.setScene("main") # res.playSong('background1') game.run() game.quit()
def main(): config_file = os.path.join(os.path.dirname(__file__), 'burningkingdoms.cfg') config = Config(config_file) game = Game(config) game.main_loop()
def main(): signal.signal(signal.SIGINT, signal_handler) resourceManager.init('assets/', imgs) config = Config('config.json') gui.loadSkin(config.skin) game = Game(config) game.init() game.addScene("edit", Editor(game)) game.setScene("edit", dict(mapName=config.map)) game.run() game.quit()
def colision_coordinates_plot(): flappy_game = Game(200, -200, -5, 30, 20, 1, 1, -3, 0, 0, 5, True) flappy_game.game_main_loop()
def time_alive_box_plot(): flappy_game = Game(200, -200, -5, 30, 20, 1, 1, -3, 0, 0, 5, True) flappy_game.game_main_loop()
def time_alive_proximity_threshold(): proximity = randint(1, 70) flappy_game = Game(200, -200, -5, 30, 20, 1, 1, -3, 0, 0, proximity, True) flappy_game.game_main_loop()
def time_alive_per_obstacle_spawn_time(): rand_density = randint(1, 8) flappy_game = Game(200, -200, -5, 30, 20, 1, rand_density, -3, 0, 0, 5, True) flappy_game.game_main_loop()