def main(screen, player: str): input_service = Input_Service(screen) output_service = Output_Service(screen) director = Director(input_service, output_service, player) results = director.start_game() return results
def main(): window = arcade.Window(constants.SCREEN_WIDTH, constants.SCREEN_HEIGHT, constants.SCREEN_TITLE) views = {} game = Director(views) game_state = GameState() start_screen = StartScreen(views) controls = ControlScreen(views) game_over = GameOverView(views) win_screen = WinScreen(views) views['window'] = window views['game'] = game views['start_screen'] = start_screen views['controls'] = controls views['game_over'] = game_over views['win_screen'] = win_screen views['game_state'] = game_state views['window'].show_view(views['start_screen']) game_view = views['start_screen'] game_view.setup() arcade.run()
def main(screen): # create the cast {key: tag, value: list} cast = {} # create paddle x = int(constants.MAX_X / 2) y = int(constants.MAX_Y - 2) position = Point(x, y) paddle = Actor() paddle.set_text("===========") paddle.set_position(position) cast["paddle"] = [paddle] # create bricks cast["brick"] = [] for x in range(5, 75): for y in range(2, 6): position = Point(x, y) brick = Actor() brick.set_text("*") brick.set_position(position) cast["brick"].append(brick) #create ball x = int(constants.MAX_X / 2) y = int(constants.MAX_Y / 2) position = Point(x, y) velocity = Point(1, -1) ball = Actor() ball.set_text("@") ball.set_position(position) ball.set_velocity(velocity) cast["ball"] = [ball] position = Point(0, 0) score = Actor() score.set_text(f"Score: ") score.set_position(position) score.set_velocity(position) cast["score"] = [score] # create the script {key: tag, value: list} script = {} input_service = InputService(screen) output_service = OutputService(screen) control_actors_action = ControlActorsAction(input_service) move_actors_action = MoveActorsAction() handle_collisions_acition = HandleCollisionsAction() draw_actors_action = DrawActorsAction(output_service) script["input"] = [control_actors_action] script["update"] = [move_actors_action, handle_collisions_acition] script["output"] = [draw_actors_action] # start the game director = Director(cast, script) director.start_game()
def main(): cast = {} cast["cycles"] = [] cycle_x = 0 for _ in range(constants.NUM_CYCLES): trail = [] cycle_x += round(constants.MAX_X / (constants.NUM_CYCLES + 1)) position = Point(cycle_x, constants.CYCLE_Y) velocity = Point(0, constants.CYCLE_SPEED) cycle = Cycle(position, velocity, constants.CYCLE_IMAGE) trail.append(cycle) for j in range(1, constants.TRAIL_LENGTH + 1): if j == 1: k = constants.CYCLE_IMG_SCALE else: k = constants.TRAIL_IMG_SCALE position = Point(cycle_x, constants.CYCLE_Y - (j * k)) velocity = cycle.get_velocity() segment = Segment(position, velocity, constants.TRAIL_IMAGE) trail.append(segment) cast["cycles"].append(trail) obstacles = [] while len(obstacles) <= constants.NUM_OBST: x = random.randint(0 + constants.OBST_WIDTH, constants.MAX_X - constants.OBST_WIDTH) y = random.randint(0 + constants.OBST_HEIGHT, constants.MAX_Y - constants.OBST_HEIGHT) obstacle = Obstacle(x, y) for trail in cast["cycles"]: cycle = trail[0] if not obstacle.collides_with_sprite(cycle): if obstacles: for other in obstacles: if not obstacle.collides_with_sprite(other): obstacles.append(obstacle) else: obstacles.append(obstacle) cast["obstacles"] = obstacles script = {} input_service = InputService() output_service = OutputService() control_actors_action = ControlActorsAction(input_service) move_actors_action = MoveActorsAction() handles_collisions_action = HandleCollisionsAction() draw_actors_action = DrawActorsAction(output_service) script["input"] = [control_actors_action] script["update"] = [move_actors_action, handles_collisions_action] script["output"] = [draw_actors_action] director = Director(cast, script, input_service) director.setup() arcade.run()
def main(screen): # create the cast {key: tag, value: list} cast = {} x = int(constants.MAX_X / 2) y = int(constants.MAX_Y - 1) position = Point(x, y) paddle = Player() paddle.set_position(position) cast["paddle"] = [paddle] cast["brick"] = [] for x in range(5, 75): for y in range(2, 6): position = Point(x, y) brick = Brick() brick.set_text("*") brick.set_position(position) cast["brick"].append(brick) x = int(constants.MAX_X / 2) y = int(constants.MAX_Y / 2) position = Point(x, y) velocity = Point(1, -1) ball = Ball() ball.set_text("@") ball.set_position(position) ball.set_starting_position(position) ball.set_velocity(velocity) cast["ball"] = [ball] score = Score() score.set_position(Point(4, 0)) cast["score"] = [score] lives = Lives() lives.set_position(Point(67, 0)) cast["lives"] = [lives] # create the script {key: tag, value: list} script = {} input_service = InputService(screen) output_service = OutputService(screen) control_actors_action = ControlActorsAction(input_service) move_actors_action = MoveActorsAction() handle_collisions_acition = HandleCollisionsAction() draw_actors_action = DrawActorsAction(output_service) script["input"] = [control_actors_action] script["update"] = [move_actors_action, handle_collisions_acition] script["output"] = [draw_actors_action] # start the game director = Director(cast, script) director.start_game()
def main(): cast = {} cast["cycles"] = [] cycle_x = 0 for _ in range(constants.NUM_CYCLES): cycle_x += round(constants.MAX_X/(constants.NUM_CYCLES + 1)) cycle = Cycle(cycle_x, constants.CYCLE_Y, constants.CYCLE_IMAGE) cast["cycles"].append(cycle) """ TRAIL LOGIC """ cast["obstacles"] = [] while len(cast["obstacles"]) <= constants.NUM_OBST: x = random.randint(0 + constants.OBST_WIDTH ,constants.MAX_X - constants.OBST_WIDTH) y = random.randint(0 + constants.OBST_HEIGHT ,constants.MAX_Y - constants.OBST_HEIGHT) obstacle = Obstacle(x, y) for cycle in cast["cycles"]: if not obstacle.collides_with_sprite(cycle): if cast["obstacles"]: for other in cast["obstacles"]: if not obstacle.collides_with_sprite(other): cast["obstacles"].append(obstacle) else: cast["obstacles"].append(obstacle) script = {} input_service = InputService() output_service = OutputService() control_actors_action = ControlActorsAction(input_service) move_actors_action = MoveActorsAction() handles_collisions_action = HandleCollisionsAction() draw_actors_action = DrawActorsAction(output_service) script["input"] = [control_actors_action] script["update"] = [move_actors_action, handles_collisions_action] script["output"] = [draw_actors_action] director = Director(cast,script,input_service) director.setup() arcade.run()
def main(): cast = {} cast["cycles"] = [] cast["obstacles"] = arcade.SpriteList() cycle_x = 0 for i in range(constants.NUM_CYCLES): trail = [] cycle_x += round(constants.MAX_X / (constants.NUM_CYCLES + 1)) position = Point(cycle_x, constants.CYCLE_Y) velocity = Point(0, constants.CYCLE_SPEED) if i == 0: img = constants.CYCLE_IMAGE else: img = constants.AI_IMAGE cycle = Cycle(position, velocity, img) trail.append(cycle) light_trail = arcade.SpriteList() trail.append(light_trail) cast["cycles"].append(trail) cast["obstacles"].append(cycle) script = {} input_service = InputService() output_service = OutputService() control_actors_action = ControlActorsAction(input_service) move_actors_action = MoveActorsAction() handles_collisions_action = HandleCollisionsAction() draw_actors_action = DrawActorsAction(output_service) script["input"] = [control_actors_action] script["update"] = [move_actors_action, handles_collisions_action] script["output"] = [draw_actors_action] director = Director(cast, script, input_service) director.setup() arcade.run()
def main(): cast = {} cast["cycles"] = [] cast["obstacles"] = [] cycle_x = 0 for _ in range(constants.NUM_CYCLES): cycle_x += ROUND(constants.MAX_X / (constants.NUM_CYCLES + 1)) cycle = Cycle(cycle_x, constants.CYCLE_Y) cast["cycles"].append(cycle) """ TRAIL LOGIC """ for _ in range(constants.NUM_OBST): """ CHECK FOR OBSTACLE OVERLAP """ obst_x = random.randint(0, constants.MAX_X) obst_y = random.randint(0, constants.MAX_Y) obstacle = Obstacle(obst_x, obst_y) cast["obstacles"].append(obstacle) script = {} input_service = InputService() output_service = OutputService() control_actors_action = ControlActorsAction(input_service) move_actors_action = MoveActorsAction() handles_collisions_action = HandleCollisionsAction() draw_actors_action = DrawActorsAction(output_service) script["input"] = [control_actors_action] script["update"] = [move_actors_action, handles_collisions_action] script["output"] = [draw_actors_action] director = Director(cast, script, input_service) batter.setup() arcade.run()
def main(): # create the cast {key: tag, value: list} cast = {} cast["players"] = [] cast["players"].append(Player("left", True)) cast["players"].append(Player("right", False)) # create the script {key: tag, value: list} script = {} control_actors_action = ControlActorsAction() move_actors_action = MoveActorsAction() handle_collisions_action = HandleCollisionsAction() key_release_action = KeyReleaseActon() draw_actors_action = DrawActorsAction() script[Director.ON_KEY_PRESS] = [control_actors_action] script[Director.ON_KEY_RELEASE] = [key_release_action] script[Director.ON_UPDATE] = [move_actors_action, handle_collisions_action] script[Director.ON_DRAW] = [draw_actors_action] # start the game director = Director(constants.MAX_X, constants.MAX_Y) director.direct_scene(cast, script) arcade.run()
from game.director import Director director = Director() director.start_game()
def main(): cast = {} cast["cycles"] = [] cycle_x = 0 for _ in range(constants.NUM_CYCLES): trail = [] cycle_x += round(constants.MAX_X / (constants.NUM_CYCLES + 1)) position = Point(cycle_x, constants.CYCLE_Y) velocity = Point(0, constants.CYCLE_SPEED) cycle = Cycle(position, velocity, constants.CYCLE_IMAGE) trail.append(cycle) light_trail = arcade.SpriteList() trail.append(light_trail) cast["cycles"].append(trail) """ obstacles = [] for i in range(constants.NUM_OBST): if i % 4 == 0: x1 = 0 x2 = constants.MAX_X / 2 y1 = constants.MAX_Y / 2 y2 = constants.MAX_Y elif i % 4 == 1: x1 = constants.MAX_X / 2 x2 = constants.MAX_X y1 = constants.MAX_Y / 2 y2 = constants.MAX_Y elif i % 4 == 2: x1 = constants.MAX_X / 2 x2 = constants.MAX_X y1 = 0 y2 = constants.MAX_Y / 2 elif i % 4 == 3: x1 = 0 x2 = constants.MAX_X / 2 y1 = 0 y2 = constants.MAX_Y / 2 x = random.randint(x1 + constants.OBST_WIDTH, x2 - constants.OBST_WIDTH) y = random.randint(y1 + constants.OBST_HEIGHT, y2 - constants.OBST_HEIGHT) obstacle = Obstacle(x, y) for trail in cast["cycles"]: cycle = trail[0] if not obstacle.collides_with_sprite(cycle): obstacles.append(obstacle) cast["obstacles"] = obstacles """ script = {} input_service = InputService() output_service = OutputService() control_actors_action = ControlActorsAction(input_service) move_actors_action = MoveActorsAction() handles_collisions_action = HandleCollisionsAction() draw_actors_action = DrawActorsAction(output_service) script["input"] = [control_actors_action] script["update"] = [move_actors_action, handles_collisions_action] script["output"] = [draw_actors_action] director = Director(cast, script, input_service) director.setup() arcade.run()
def main(screen): input_service = InputService(screen) output_service = OutputService(screen) director = Director(input_service, output_service) director.start_game()
def on_mouse_press(self, _x, _y, _button, _modifiers): """If mouse is pressed, start the game.""" director = Director(self._cast, self._script, self._input) director.setup() self.window.show_view(director)
# get_image_data()) #game_window.set_icon(icon) class Score: def __init__(self): self.meters = 0 self.top = 0 def __iadd__(self, value): self.meters += value if self.meters > self.top: self.top = self.meters return self score = Score() title = Title(assets, score) engine = Engine(assets, score) director = Director(constants.VWIDTH * 2, constants.VHEIGHT * 2, caption="Fuel4TheLight", vwidth=constants.VWIDTH, vheight=constants.VHEIGHT) director.set_background_color(0., 0., 0.) Director.add_scene("title", title) Director.add_scene("engine", engine) Director.set_scene("title") pyglet.app.run()
def on_mouse_press(self, _x, _y, _button, _modifiers): start_game = Director() self.window.show_view(start_game)
from game.director import Director director = Director() # Calls the Director Class director.start_game() # Calls start_game method from Director Class