def __init__(self, screen:pygame.Surface, args: dict, parent): """ This is the object ALL objects MUST inherit from to be used in a room. This is the parent of ALL objects. :param screen: The screen to draw the object to :param args: The dictionary of properties specified in the XML. NOTE: Any property defined in a tag, will have the '@' infront of it :param parent: The room the object will live in """ self.screen = screen self.args = args self.parent = parent self.angle = 0 self.should_center_width = get_mandatory(args, "@x", str) == "c" self.should_center_height = get_mandatory(args, "@y", str) == "c" self.locked = get_optional(args, "@locked", "false") self.screen_w, self.screen_h = self.screen.get_size() self.display = Color(screen, (255, 0, 255), 10, 10) self.w, self.h = self.display.get_size() if self.should_center_width: self.x = self.center_width() else: self.x = get_mandatory(args, "@x", int) if self.should_center_height: self.y = self.center_height() else: self.y = get_mandatory(args, "@y", int) self.on_screen_cache = True self.on_mouse_over_cache = False self.deleted = False self.ticker = Ticker() self.time_delta = self.ticker.tick self.states = {} self.state = None self.x_delta = 0 self.y_delta = 0 self.model_type = type(self).__name__ self.debug_color = get_sys_var("debug-color") self.siblings = self.parent.props.array self.oncreate()
def system_onroomenter(self): self.ticker = Ticker()
def __init__(self, screen:pygame.Surface, args: dict, parent): """ This is the object ALL objects MUST inherit from to be used in a room. This is the parent of ALL objects. :param screen: The screen to draw the object to :param args: The dictionary of properties specified in the XML. :param parent: The room the object will live in """ self.screen = screen self.args = self.modify_args(args) self.parent = parent self.angle = 0 # self.should_center_width = get_mandatory(args, "@x", str) == "c" # self.should_center_height = get_mandatory(args, "@y", str) == "c" self.locked = get_optional(args, "locked", "false") self.screen_w, self.screen_h = self.screen.get_size() self.display = Color(screen, (255, 0, 255), 10, 10) w, h = self.display.get_size() self.w = get_optional(args, "w", None) self.h = get_optional(args, "h", None) if self.w is None: self.w = w if self.h is None: self.h = h self.positional_vars = {} self.reload_vars() self.x = None self.y = None self.recalculate_position() self.on_screen_cache = True self.on_mouse_over_cache = False self.deleted = False self.ticker = Ticker() self.time_delta = self.ticker.tick self.states = {} self.state = None self.x_delta = 0 self.y_delta = 0 self.model_type = type(self).__name__ self.debug_color = get_sys_var("debug-color") self.siblings = self.parent.props.array self.oncreate() self.frequency_monitor_thread = None self.zindex = 10