def update_event(self): """ Update the states of Input Event """ window = self.screen input_manager.update_joy_event() for event in window.events: input_manager.update_keyboard_event(event) if type(event) is sfml.CloseEvent: self.finish = True elif type(event) is sfml.MouseButtonEvent: screen_ratio = float(self.screen_size.y) / Vector2(self.screen.size).y from levels.gamestate import GameState if get_level().__class__ == GameState: log((Vector2(event.position) * screen_ratio + get_level().screen_pos).get_tuple()) elif type(event) is sfml.ResizeEvent: new_size = event.size
def update_event(): """ Update the states of Input Event """ if CONST.render == 'sfml': from engine.init import engine window = engine.screen update_joy_event() for event in window.events: update_keyboard_event(event) if type(event) is sfml.CloseEvent: from engine.init import engine engine.finish = True elif type(event) is sfml.MouseButtonEvent: screen_ratio = float(engine.get_screen_size().y)/Vector2(engine.screen.size).y from levels.gamestate import GameState if get_level().__class__ == GameState: log((Vector2(event.position)*screen_ratio+get_level().screen_pos).get_tuple()) elif type(event) is sfml.ResizeEvent: new_size = event.size elif CONST.render == 'pookoo': update_keyboard_event()
def parse_event(event_dict): """Dynamic parsing of DialogEvent""" text = get_element(event_dict, "text") if text is None: return None text2 = get_element(event_dict, "text2") if text2 is None: text2 = '' dialog_event = DialogEvent(get_level(), text, text2) answers = get_element(event_dict, "answers") if answers is not None: for answer_key in answers: if isinstance(answers[answer_key],dict): answers[answer_key] = parse_event_json(answers[answer_key], dialog_event) elif isinstance(answers[answer_key], CONST.string_type): answers[answer_key] = load_event(answers[answer_key], dialog_event) dialog_event.set_answers(answers) return dialog_event
def parse_event(event_dict): new_level_name = get_element(event_dict,"name") if new_level_name: return SwitchEvent(get_level(),new_level_name) else: log("Invalid arg name for SwitchEvent")