Build the map image, stores the needed modules and prepares rendering in Hero Mode
(self, hud, input_control)
| 938 | exit_game() |
| 939 | |
| 940 | def start(self, hud, input_control): |
| 941 | """Build the map image, stores the needed modules and prepares rendering in Hero Mode""" |
| 942 | self.world, self.town_map = self._get_data_from_carla() |
| 943 | |
| 944 | settings = self.world.get_settings() |
| 945 | settings.no_rendering_mode = self.args.no_rendering |
| 946 | self.world.apply_settings(settings) |
| 947 | |
| 948 | # Create Surfaces |
| 949 | self.map_image = MapImage( |
| 950 | carla_world=self.world, |
| 951 | carla_map=self.town_map, |
| 952 | pixels_per_meter=PIXELS_PER_METER, |
| 953 | show_triggers=self.args.show_triggers, |
| 954 | show_connections=self.args.show_connections, |
| 955 | show_spawn_points=self.args.show_spawn_points) |
| 956 | |
| 957 | self._hud = hud |
| 958 | self._input = input_control |
| 959 | |
| 960 | self.original_surface_size = min(self._hud.dim[0], self._hud.dim[1]) |
| 961 | self.surface_size = self.map_image.big_map_surface.get_width() |
| 962 | |
| 963 | self.scaled_size = int(self.surface_size) |
| 964 | self.prev_scaled_size = int(self.surface_size) |
| 965 | |
| 966 | # Render Actors |
| 967 | self.actors_surface = pygame.Surface((self.map_image.surface.get_width(), self.map_image.surface.get_height())) |
| 968 | self.actors_surface.set_colorkey(COLOR_BLACK) |
| 969 | |
| 970 | self.vehicle_id_surface = pygame.Surface((self.surface_size, self.surface_size)).convert() |
| 971 | self.vehicle_id_surface.set_colorkey(COLOR_BLACK) |
| 972 | |
| 973 | self.border_round_surface = pygame.Surface(self._hud.dim, pygame.SRCALPHA).convert() |
| 974 | self.border_round_surface.set_colorkey(COLOR_WHITE) |
| 975 | self.border_round_surface.fill(COLOR_BLACK) |
| 976 | |
| 977 | # Used for Hero Mode, draws the map contained in a circle with white border |
| 978 | center_offset = (int(self._hud.dim[0] / 2), int(self._hud.dim[1] / 2)) |
| 979 | pygame.draw.circle(self.border_round_surface, COLOR_ALUMINIUM_1, center_offset, int(self._hud.dim[1] / 2)) |
| 980 | pygame.draw.circle(self.border_round_surface, COLOR_WHITE, center_offset, int((self._hud.dim[1] - 8) / 2)) |
| 981 | |
| 982 | scaled_original_size = self.original_surface_size * (1.0 / 0.9) |
| 983 | self.hero_surface = pygame.Surface((scaled_original_size, scaled_original_size)).convert() |
| 984 | |
| 985 | self.result_surface = pygame.Surface((self.surface_size, self.surface_size)).convert() |
| 986 | self.result_surface.set_colorkey(COLOR_BLACK) |
| 987 | |
| 988 | # Start hero mode by default |
| 989 | self.select_hero_actor() |
| 990 | self.hero_actor.set_autopilot(False) |
| 991 | self._input.wheel_offset = HERO_DEFAULT_SCALE |
| 992 | self._input.control = carla.VehicleControl() |
| 993 | |
| 994 | # Register event for receiving server tick |
| 995 | weak_self = weakref.ref(self) |
| 996 | self.world.on_tick(lambda timestamp: World.on_world_tick(weak_self, timestamp)) |
| 997 |
no test coverage detected