def __init__(self, master, car_id: int, **kwargs): self.__height = 150 Image.__init__(self, RESOURCES.IMG["garage_cars"][car_id], height=self.__height) Clickable.__init__(self, master, **kwargs, highlight_thickness=0) self.__id = car_id self.__all_max_speed = list() self.__all_acceleration = list() self.__all_maniablities = list() self.__all_braking = list() for infos in CAR_INFOS.values(): self.__all_max_speed.append(infos["max_speed"]) self.__all_acceleration.append(infos["acceleration"]) self.__all_maniablities.append(infos["maniability"]) self.__all_braking.append(infos["braking"]) self.take_focus(True) self.disable_key_joy() self.disable_mouse() self.master.bind_event(pygame.KEYDOWN, self.on_click_down) self.master.bind_event(pygame.KEYUP, self.on_click_up) self.master.bind_event(pygame.JOYHATMOTION, self.on_click_down) self.master.bind_event(pygame.JOYHATMOTION, self.on_click_up)
def __init__(self, name: str, boxes: Sequence[tuple[int, int]], orient: str): Image.__init__(self, RESOURCES.IMG[name]) self.name = name self.__orient = Ship.VERTICAL self.ship_size = len(boxes) self.boxes_pos = [tuple(box_pos) for box_pos in boxes] self.set_height(self.ship_size * BOX_SIZE[0]) self.orient = orient self.__boxes_covered = list()
def __init__(self, master, ship_name: str, ship_size: int): Image.__init__(self, RESOURCES.IMG[ship_name]) self.name = ship_name self.__orient = ShipSetup.VERTICAL self.master = master self.ship_size = ship_size self.orient = ShipSetup.HORIZONTAL self.set_width(self.ship_size * BOX_SIZE[0]) self.clicked = False self.on_move = False self.mouse_offset = (0, 0) self.default_center = (0, 0) self.center_before_click = (0, 0) self.__boxes_covered = list() self.master.bind_event(pygame.MOUSEBUTTONDOWN, self.select_event) self.master.bind_event(pygame.MOUSEBUTTONUP, self.unselect_event) self.master.bind_event(pygame.MOUSEMOTION, self.move_event)