Ejemplo n.º 1
0
    def load_scenario(self):
        """Load the chosen Scenario."""
        self.rendering_mode = RenderingMode.LOAD_SCENARIO
        # Unpickle the Scenario file
        self.scenario = load(open(self.scenario, "rb"))

        # Log Version of the scenario and code
        print("Loading Scenario Version %s with code base Version %s" %
              (self.scenario.get_version(), __version__))

        license = self.scenario.get_license()
        if license is not None:
            print("Scenario licensed as follows:")
            print("")
            print(license)
        else:
            print("No license provided in scenario file.")

        # Get the logo to display (if any)
        self.logo = self.scenario.get_logo()

        # Load variables into memory
        self.step = self.scenario.get_board_step()
        self.height = self.scenario.get_logical_height() * self.step
        self.width = self.scenario.get_logical_width() * self.step

        self.board = Board(self.scenario)

        self.robot = BeeBot(self.scenario)

        self.clock = pygame.time.Clock()

        buttons_on_the_left = True

        self.create_buttons(buttons_on_the_left)

        if buttons_on_the_left:
            # Make space for:
            # - the Buttons to the right of the map.
            # - the CommandLog below the map.
            self.size = (self.width + 400, self.height + 30)
            # Create the empty CommandLog
            self.command_log = CommandLog(Point(0, self.height),
                                          (self.width, 30))
        else:
            # Make space for:
            # - the Buttons below the map.
            # - the CommandLog to the right of the map.
            self.size = (self.width + 30, self.height + 400)
            # Create the empty CommandLog
            self.command_log = CommandLog(Point(self.width, 0),
                                          (30, self.height))

        # Only want to do this once, so sadly can't do it in the rendering
        # loop without a potential race condition as
        # size gets set by loading the Scenario
        if self._rendering_running:
            self.screen = pygame.display.set_mode(self.size)
Ejemplo n.º 2
0
    def setUp(self):
        """
        Create a minimal Scenario and use it to create a BeeBot.

        The Scenario is 5x5 (logical and pixel size)
        with the BeeBot in the centre, and no Obstacles or Goals.
        """
        # Create the minimal Scenario
        test_scenario = Scenario('Test')
        test_scenario.set_board_step(1)
        test_scenario.set_logical_width(5)
        test_scenario.set_logical_height(5)
        test_scenario.set_beebot_start_position(2, 2)
        test_scenario.set_beebot_sprite('img/Default/robot.jpg')
        # Create the test BeeBot
        self.test_robot = BeeBot(test_scenario)
Ejemplo n.º 3
0
    def load_scenario(self):
        """Load the chosen Scenario."""
        self.rendering_mode = RenderingMode.LOAD_SCENARIO
        # Unpickle the Scenario file
        self.scenario = load(open(self.scenario, "rb"))

        # Log Version of the scenario and code
        print("Loading Scenario Version %s with code base Version %s" %
              (self.scenario.get_version(), __version__))

        license = self.scenario.get_license()
        if license is not None:
            print("Scenario licensed as follows:")
            print("")
            print(license)
        else:
            print("No license provided in scenario file.")

        # Get the logo to display (if any)
        self.logo = self.scenario.get_logo()

        # Load variables into memory
        self.step = self.scenario.get_board_step()
        self.height = self.scenario.get_logical_height() * self.step
        self.width = self.scenario.get_logical_width() * self.step

        self.board = Board(self.scenario)

        self.robot = BeeBot(self.scenario)

        self.clock = pygame.time.Clock()

        buttons_on_the_left = True

        self.create_buttons(buttons_on_the_left)

        if buttons_on_the_left:
            self.size = (self.width + 400, self.height)
        else:
            self.size = (self.width, self.height + 400)

        self.screen = pygame.display.set_mode(self.size)