def run(args=None): world = esper.World() window = WindowProcessor(1280, 720, "A Window", resizable=True) world.add_processor(window) world.add_processor(MoveProcessor()) world.add_processor(EditorProcessor(window)) factory = Factory(world, window) factory.create_world() pyglet.clock.schedule_interval(world.process, 1 / 60.0) pyglet.app.run()
def on_mouse_press(self, x, y, button, modifiers): wx = x wy = y if self._has_cam(): wx, wy = self.cam.to_world(x, y) if button & 1 == 1: if not self._get_wire(wx, wy): self.drag_ent, self.drag_line, self.drag_wire, self.sel = Factory.create_wire( wx, wy, wx, wy) # calc except list for self wire self.except_list.append(self.sel) for s1 in self.sel.segs: n1 = s1.another(self.sel) if n1 in self.except_list: continue self.except_list.append(n1) for s2 in n1.segs: n2 = s2.another(n1) if n2 in self.except_list: continue self.except_list.append(n2)
def test_factory_env_configuration(): factory_app = Factory('testing') assert factory_app.environment == 'testing' factory_app.set_flask() factory_app.environment = 'development' assert factory_app.environment == 'development'
from app.game import Game from app.factory import Factory print(""" Welcome to the Guessing Game! Who you want to be? Guesser(1) Thinker(2) """) while True: game_type = int(Game.valid_input( 'Enter 1 or 2 to select the mode --> ')) if game_type in [1, 2]: break print('Sorry, we do not have that game. Try again.') game = Factory.create_game(game_type) game.play()
def on_key_press(self, symbol, modifiers): if symbol == key.I: if self._has_cam(): wx, wy = self.cam.to_world(self.window.mx, self.window.my) Factory.create_instance(wx, wy, 10, 20)
def test_create_game_with_invalid_game_type_raises_value_error(self): game_types = [-1, 0, 3, 10] for value in game_types: with self.assertRaises(ValueError) as cm: Factory.create_game(value) self.assertEqual('Game type does not exist.', cm.exception.args[0])
def test_create_game_with_valid_game_type_returns_game(self): game1 = Factory.create_game(1) self.assertIsInstance(game1, GuesserGame) game2 = Factory.create_game(2) self.assertIsInstance(game2, ThinkerGame)