def update(self): if self.immortal or (utils.current_milli_time() - self.internal_scheduler) < 0: return weight_coefficient = -1 monster_weight = g_game.monster_weight if monster_weight <= 100: weight_coefficient = utils.THREAD_LIGHT elif monster_weight <= 150: weight_coefficient = utils.THREAD_NORMAL elif monster_weight <= 200: weight_coefficient = utils.THREAD_MEDIUM elif monster_weight <= 250: weight_coefficient = utils.THREAD_HEAVY else: weight_coefficient = utils.THREAD_VERY_HEAVY next_interval = utils.THREAD_DAMAGE_INTERVAL - (weight_coefficient * 2000) self.lose_health(utils.THREAD_DAMAGE_PER_INTERVAL) self.internal_scheduler = utils.current_milli_time() + next_interval
async def get_event_estimate(self, event_data): """ Get new event estimate time and schedule tasks to alert the event. """ del self.event_schedules[event_data['task_id']] event = event_data['name'] estimate = await get_event_estimate_time( SKYBLOCK_EVENTS[event]['endpoint'], session=self.bot.http_session) if estimate is None or estimate < (current_milli_time() + (300 * 1000)): time = (current_milli_time() / 1000.0) + 600 time = datetime.fromtimestamp(time) # Reschedule in 10 mins to get new estimate event_data['task_id'] = id(time) event_data['time'] = time self._schedule_event_task(event_data) else: time = datetime.fromtimestamp((estimate / 1000.0) - 300.0) # Schedule new event alert event_data['task_id'] = id(time) event_data['type'] = 'alert' event_data['estimate'] = estimate event_data['time'] = time self._schedule_event_task(event_data)
def __init__(self, game_i: 'game.Game'): """ :type game_i: game.Game """ super().__init__((100, 100), (36, 52)) IMAGE = pygame.image.load('assets/textures/character/main.png') self.image: List[pygame.Surface] = [ utils.get_part_i(IMAGE, cord[0:4], (36, 52), flip=(True, False) if cord[4] else (False, False)) for cord in Player.I] self.movement = [0, 0] self.speed = 10 self.speed_on_running = 6 self.speed_cycling = 4 self.speed_getter = SpeedGetter(utils.current_milli_time()) self.direction = 2 self.current_dialogue = None self.freeze_time = 0 self.is_action_press = False self.last_close_dialogue = utils.current_milli_time() self.current_menu: Optional['menu_calass.Menu'] = None self.team = [player_pokemon.PlayerPokemon.from_json(p) for p in game_i.get_save_value("team", [])] self.normalize_team() self.current_battle: Optional['battle.Battle'] = None self.speed_status = [False, False] self.is_cycling = False self.is_backhoe_loader = False self.pc: PC = PC(game_i.get_save_value("pc", []))
def test_ious_large(): # benchmarking test t = current_milli_time() for _ in range(100): b1 = np.random.randn(30, 4) b2 = np.random.randn(20, 4) iou = calculate_iou(b1, b2, dim=2) assert iou.shape == (30, 20) tdiff = current_milli_time() - t assert tdiff < 100
def __think(self): self_id = self.id while self_id in g_game.objects: self.walk_pattern.step() if (utils.current_milli_time() - self.internal_cooldown) >= 0: self.shoot_pattern.fire() self.internal_cooldown = utils.current_milli_time() + self.shoot_cooldown self.clock.tick(60)
def tick(self, display: pygame.Surface) -> bool: if self.no_init: self.no_init = False self.start = utils.current_milli_time() pst = utils.current_milli_time() - self.start if pst < 1500: for g in self.g_i: g.render(display) return False if pst < 2000: return False return True
def generate_model_output(sample, model_name): prediction, hidden_states, features = model.tokenize_and_predict( sample, model_name) start_time = current_milli_time() # build pca-layer list from hidden states tokens = features.tokens layers = [] for layer in hidden_states: # cut off padding token_vectors = layer[0][:len(tokens)] # dimensionality reduction layer_reduced = visualize.reduce(token_vectors, "pca", 2) # build json with point information points = [] for i, val in enumerate(layer_reduced[0]): point = {'x': val, 'y': layer_reduced[1][i], 'label': tokens[i]} points.append(point) layers.append(points) # build indices object question_indices = get_question_indices(tokens) # answer_indices = get_answer_indices(features) ## Decide whether to highlight ground truth or predicted answer answer_indices = prediction["start_index"], prediction["end_index"] + 1 token_indices = { 'question': { 'start': question_indices[0], 'end': question_indices[1], }, 'answer': { 'start': answer_indices[0], 'end': answer_indices[1], }, 'sups': [] } for sup in features.sup_ids: print(tokens[sup[0]:sup[1] + 1]) token_indices['sups'].append({'start': sup[0], 'end': sup[1]}) end_time = current_milli_time() logger.info("Postprocessing Time: {} ms".format(end_time - start_time)) return prediction, layers, token_indices
def post_data_to_ics(name, req, quantity, loc, address, contact_number): ics_qry = "https://fierce-bayou-28865.herokuapp.com/api/v1/covid/nootp" feed_data = { "name": name, "entity": req, "quantity": quantity if quantity else None, "city": loc, "provider_name": name, "provider_address": address if address else "Unavailable", "provider_contact": contact_number, "contact": contact_number, "link": "", "filedAt": current_milli_time() } logger.debug("data to be sent to ICS : {}".format(feed_data)) success = True try: qry_res = requests.post(ics_qry, json=feed_data) except Exception as e: logger.error(e) success = False qry_res_data = qry_res.json() logger.debug(qry_res_data) return feed_data, success
def draw_team(self, display: pygame.Surface): _x = 106 _y = 70 _time = utils.current_milli_time() - self.open_time part_time = _time % 2000 poke_y = 0 if part_time < 900: poke_y = 0 elif part_time < 950 or 1950 <= part_time: poke_y = 1 elif part_time < 1000 or 1900 <= part_time: poke_y = 3 elif part_time < 1900: poke_y = 5 if self.target is None: for i in range(self.player.get_non_null_team_number()): if i != self.poke_select: utils.draw_pokemon(display, self.player.team[i], (_x, _y), poke_y) else: utils.draw_pokemon(display, self.player.team[i], (_x, _y), poke_y, color=(0, 0, 0), text_color=(255, 255, 255), need_arrow=True) _y += 80 else: utils.draw_pokemon(display, self.target, (_x, _y), poke_y)
def __init__(self, player, escape_call_back: Optional[Callable[[], NoReturn]] = None, choice_call_back: Optional[Callable[[int], NoReturn]] = None ): super().__init__(player) self.escape_call_back = escape_call_back self.choice_call_back = choice_call_back self.selected = 0 self.action_type = 0 self.action_selected = -1 self.move = -1 self.keys = { game.get_game_instance().get_message("back"): option.KEY_QUITE, game.get_game_instance().get_message("move_pokemon"): option.KEY_BIKE, game.get_game_instance().get_message("select"): option.KEY_ACTION } self.arrow = utils.ARROW self.open_time = utils.current_milli_time() self.text_2 = [(game.FONT_20.render(game.get_game_instance().get_message(t), True, (0, 0, 0)), game.FONT_20.render(game.get_game_instance().get_message(t), True, (255, 255, 255))) for t in ["summary", "move", "heal", "object", "back"]] self.box_object = [(game.FONT_20.render(game.get_game_instance().get_message(t), True, (0, 0, 0)), game.FONT_20.render(game.get_game_instance().get_message(t), True, (255, 255, 255))) for t in ["open_bag", "put_in_bag", "back"]] self.cat_image = utils.color_image(utils.get_part_i(utils.MENU_IMAGE, (0, 0, 64, 64)), (0, 0, 0, 255))
def load_model(model_file, model_type, cache_dir): start_time = current_milli_time() # Load a pretrained model that has been fine-tuned config = BertConfig.from_pretrained(model_type, output_hidden_states=True, cache_dir=cache_dir) pretrained_weights = torch.load(model_file, map_location=torch.device('cpu')) model = BertForQuestionAnswering.from_pretrained(model_type, state_dict=pretrained_weights, config=config, cache_dir=cache_dir) end_time = current_milli_time() logger.info("Model Loading Time: {} ms".format(end_time - start_time)) return model
def __init__(self, font): #test purposes self.count = 0 self.start_time = utils.current_milli_time() self.weight_text = "Thread Tension: " self.weight_text_1 = None self.weight_text_render = None self.weight_text_render_1 = None self.level_text = "Level: " self.level_text_1 = None self.level_text_render = None self.level_text_render_1 = None self.time_text = "Time: " self.time_text_1 = None self.time_text_render = None self.time_text_render_1 = None self.font = font self.weight = ["LIGHT", "NORMAL", "MEDIUM", "HEAVY", "VERY HEAVY"] self.weight_colors = ['blue', 'green', 'yellow', 'orange', 'red'] self.update_text()
def move(self, co: 'collision') -> NoReturn: """ :type co: collision.Collision """ move = self.update_direction() speed = self.speed_cycling if self.is_cycling else ( self.speed_on_running if self.speed_status[1] else self.speed) speed = self.speed_getter.get_delta(utils.current_milli_time(), speed) speed = min(10, speed) if move: offset_y = (-1 if self.direction == 0 else 1 if self.direction == 2 else 0) * speed offset_x = (-1 if self.direction == 1 else 1 if self.direction == 3 else 0) * speed else: offset_x, offset_y = 0, 0 box = self.get_box() col = co.get_collision(box, offset_x, offset_y) if self.freeze_time != 0: return if col and (not game.game_instance.ignore_collision): self.set_render_from_scroll(game.came_scroll, col) else: self.rect.x += offset_x self.rect.y += offset_y
def render(self, display): display.fill((255, 255, 255)) pygame.draw.polygon(display, (246, 250, 253), ((0, 0), (132, 0), (40, 600), (0, 600))) # pygame.draw.polygon(display, (206, 51, 65), TeamMenu.t_poly_2) g_x = 106 g_y = 60 _time = utils.current_milli_time() - self.open_time part_time = _time % 2000 poke_y = 0 if part_time < 900: poke_y = 0 elif part_time < 950 or 1950 <= part_time: poke_y = 1 elif part_time < 1000 or 1900 <= part_time: poke_y = 3 elif part_time < 1900: poke_y = 5 for i in range(self.player.get_non_null_team_number()): self.draw_pokemon(display, self.player.team[i], g_x, g_y, poke_y, (0, 0, 0) if self.selected == i else (255, 255, 255), (0, 0, 0) if self.selected != i else (255, 255, 255) ) g_y += 90 # action hud if self.action_selected != -1: _y = 60 + 90 * self.selected _x = 1060 * 0.31 utils.draw_select_box(display, _x, _y, self.text_2, self.action_selected, 100)
def get_image(self) -> pygame.Surface: if self.freeze_time == 0 and self.speed_status[0]: if self.is_cycling: if self.is_backhoe_loader: return self.image[ self.direction * 12 + ((self.get_half(utils.current_milli_time() % 600, 600)) + 9)] return self.image[self.direction * 12 + ((self.get_half(utils.current_milli_time() % 600, 600)) + 6)] elif self.speed_status[1]: return self.image[self.direction * 12 + ((self.get_half(utils.current_milli_time() % 350, 350)) + 3)] else: return self.image[self.direction * 12 + (self.get_half(utils.current_milli_time() % 600, 600))] else: if self.is_cycling: if self.is_backhoe_loader: return self.image[self.direction * 12 + 9] return self.image[self.direction * 12 + 6] return self.image[self.direction * 12]
def __init__(self, images: List[pygame.Surface], coord: Tuple[int, int], speed): self.__images: List[pygame.Surface] = images self.__len = len(images) self.__coord = coord self.__speed = speed self.__ticking = speed * self.__len self.__start_time = utils.current_milli_time()
def get_image(self) -> pygame.Surface: if self.freeze_time == 0 and self.speed_status[0]: if self.is_cycling: return self.image[self.direction * 9 + ( (self.get_half(utils.current_milli_time() % 600, 600)) + 5)] elif self.speed_status[1]: return self.image[self.direction * 9 + ( (self.get_half(utils.current_milli_time() % 350, 350)) + 3)] else: return self.image[self.direction * 9 + ( self.get_half(utils.current_milli_time() % 600, 600))] else: if self.is_cycling: return self.image[self.direction * 9 + 7] return self.image[self.direction * 9]
def tick(self, display: Surface) -> bool: if not self._init: self._init = True ask = game.game_instance.get_message("yes"), \ game.game_instance.get_message("no") game.game_instance.player.open_dialogue( hud.QuestionDialog('battle.evolution_ask', self.callback, ask, speed=20, need_morph_text=True, style=2, text_var=[self.poke.get_name(True)])) if self.question_answer is not None: # no if self.question_answer == 1: return True # yes else: ps_t = utils.current_milli_time() - self._start # if ps_t < 10_000: display.blit(self.bg, (0, 0)) if ps_t < 8_000: x = ps_t / (8000 / 10) f = lambda x: math.cos(x * 10) + 0.2 * x - 1 img = displayer.get_poke( PATH( str(self.new_base_poke.id_ if f(x) >= 0 else self. base_poke.id_)), 3) display.blit(img, (530 - img.get_size()[0] // 2, 300 - img.get_size()[1] // 2)) else: img = displayer.get_poke(PATH(str(self.new_base_poke.id_)), 3) display.blit(img, (530 - img.get_size()[0] // 2, 300 - img.get_size()[1] // 2)) if not self.action: sound_manager.start_in_first_empty_taunt( sounds.EVOLUTION) self.action = True game.game_instance.player.open_dialogue( hud.Dialog("battle.evolution", speed=100, need_morph_text=True, callback=self.end_callback, text_var=[ self.poke.get_name(True), self.new_base_poke.get_name(True) ])) self.poke.set_id(self.new_id) elif self.need_end: game.game_instance.player.close_dialogue() del self.bg sounds.EVOLUTION.un_load() return True return False
def tick(self, display: pygame.Surface) -> bool: if not self._init: self._init = True if 0 <= self.__i < 6: sound_manager.start_in_first_empty_taunt(sounds.LEVEL_UP) game.game_instance.player.open_dialogue( hud.Dialog( "battle.xp.poke_level_up", need_morph_text=True, none_skip=True, style=2, speed=25, text_var=[self.poke.get_name(True), self.poke.lvl])) else: self.action = 2 draw_xp_pokemon(display, [(key, value and value[0] > 0) for key, value in zip(self.__xp_tab, self.__edit)]) if self.action == 1: if self.__i != -1: self.action += 1 self._start = utils.current_milli_time() else: self.action = 3 if 0 <= self.__i < 6: fusion = 1 if self.action > 1: fusion = 1 - min( (utils.current_milli_time() - self._start) / 200, 1) draw_pokemon_stats(display, self.poke, self.__edit[self.__i][1], fusion) if self.action > 2: if self.__i != -1: self._bat.TO_SHOW.insert( 0, lambda: self._bat.start_new_animation( PokemonWonAttackAnimation( self._bat, self.__xp_tab, self.__i_, self.__edit, self.get_next_i(self.__i), self.attack_edit))) # self._bat.TO_SHOW.append(lambda: self._bat.start_new_animation(XpAnimationAdd( # self._bat, self.__xp_tab, self.get_next_i(self.__i), self.__edit))) game.game_instance.player.close_dialogue() return True return False
def render(self, display): display.fill((255, 255, 255)) pygame.draw.polygon(display, (241, 65, 78), TeamMenu.t_poly_1) pygame.draw.polygon(display, (206, 51, 65), TeamMenu.t_poly_2) pygame.draw.rect(display, (0, 0, 0), (0, 570, 1060, 30)) display.blit(self.cat_image, (10, 10)) display.blit(game.FONT_BOLD_58.render( game.get_game_instance().get_message("team").upper(), True, (0, 0, 0)), (74, 10)) g_x = SURFACE_SIZE[0] * 0.1 g_y = 70 _time = utils.current_milli_time() - self.open_time part_time = _time % 2000 poke_y = 0 if part_time < 900: poke_y = 0 elif part_time < 950 or 1950 <= part_time: poke_y = 1 elif part_time < 1000 or 1900 <= part_time: poke_y = 3 elif part_time < 1900: poke_y = 5 for i in range(self.player.get_non_null_team_number()): if self.move != i: color = (0, 0, 0) if self.selected == i else (255, 255, 255) text_color = (0, 0, 0) if self.selected != i else (255, 255, 255) utils.draw_pokemon(display, self.player.team[i], (int(g_x), int(g_y)), poke_y, color=color, text_color=text_color) g_y += 80 # draw move if self.move != -1: color = (0, 0, 0) if self.selected == self.move else (255, 255, 255) text_color = (0, 0, 0) if self.selected != self.move else (255, 255, 255) utils.draw_pokemon(display, self.player.team[self.move], (int(g_x + SURFACE_SIZE[0] * 0.04), int(self.selected * SURFACE_SIZE[1] * 0.15 + SURFACE_SIZE[1] * 0.05)), poke_y, color=color, text_color=text_color) select = self.player.team[self.selected] if select: display.blit(select.get_front_image(4), (SURFACE_SIZE[0] * 0.5, SURFACE_SIZE[1] * 0.2)) # action hud if self.action_selected != -1: _y = (-35 if self.selected == 5 else 40) + SURFACE_SIZE[1] * 0.15 * self.selected _x = SURFACE_SIZE[0] * 0.31 if self.action_type == 0: utils.draw_select_box(display, _x, _y, self.text_2, self.action_selected, 100) else: utils.draw_select_box(display, _x, _y, self.box_object, self.action_selected, 100) utils.draw_button_info(display, **self.keys)
def open_dialogue(self, dialogue: 'Dialog', check_last_open: int = 0, over: bool = True) -> NoReturn: if 0 < check_last_open and check_last_open > utils.current_milli_time() - self.last_close_dialogue and not over: return if self.current_dialogue and not over: return self.freeze_time = -2 self.current_dialogue = dialogue
def render(self, display: pygame.Surface) -> NoReturn: if self._style == 1: display.blit(DIALOGUE_BOX, (int( game.SURFACE_SIZE[0] * 0.05), game.SURFACE_SIZE[1] * 0.75)) color = (0, 0, 0) arrow_pos = (game.SURFACE_SIZE[0] * 0.88, game.SURFACE_SIZE[1] * 0.88) text_x = Dialog.x * 0.15 text_y = Dialog.y * 0.78 max_char = 70 else: pygame.draw.polygon(display, (40, 35, 32), Dialog.poly_6) pygame.draw.polygon(display, (50, 50, 50), Dialog.poly_7) pygame.draw.polygon(display, (40, 35, 32), Dialog.poly_8) color = (255, 255, 255) arrow_pos = (game.SURFACE_SIZE[0] * 0.73, game.SURFACE_SIZE[1] * 0.95) text_x = Dialog.x * 0.25 text_y = Dialog.y * 0.87 # text_y = t = utils.current_milli_time() if 0 < self._timed < (t - self._start_render_line): game.game_instance.player.close_dialogue() return if self._start_render_line == -1: self._start_render_line = t nb_char = (((t - self._start_render_line) // self._speed) + 1) if self._speed > 0 else ( len(self._text[self._current_line]) + 1) if nb_char > len(self._text[self._current_line]) or self._is_end_line: if self._show_line == 0 and not self._mono_line: self._show_line = 1 self._current_line += 1 self._start_render_line = t nb_char = 1 else: nb_char = len(self._text[self._current_line]) if self._display_arrow: display.blit(DOWN_ARROW, arrow_pos) self._need_enter = True self._is_end_line = True if self._show_line == 1: l = game.FONT_24.render(self._text[self._current_line - 1], True, color) display.blit(l, (text_x, text_y)) l = self._text[self._current_line] current = game.FONT_24.render(l[0:nb_char], True, color) display.blit(current, (text_x, text_y + ((game.SURFACE_SIZE[1] * 0.2 / 3) * self._show_line)))
def talk_callback(self, value, index) -> NoReturn: player = game.game_instance.player if index == 1: player.open_dialogue(hud.Dialog("dialog.poke_center_no", speed_skip=True, need_morph_text=True), over=True) else: self.have_start_song = False self.__action = utils.current_milli_time() self.__player.open_dialogue(hud.Dialog("dialog.poke_center_yes", need_morph_text=True, none_skip=True), over=True) self.__player.heal_team() return True
def press_action(self) -> bool: if not self.none_skip and ( self._need_enter or self._speed_skip or (self._timed > 0 and utils.current_milli_time() - self._open_time > self._open_time)): self._need_enter = False if self._mono_line or (self._current_line == (len(self._text) - 1)): if self._speed and not self._is_end_line: self._is_end_line = True return False else: return not self.__callback() if self.__callback else True self._is_end_line = False if self._show_line == 0 and not self._mono_line: self._show_line = 1 self._current_line += 1 self._start_render_line = utils.current_milli_time() return False
async def schedule_event(self, event): """ Schedule an event given its name. """ # Check if event is already started if any(event == schedule['name'] for schedule in self.event_schedules.values()): return f'{SKYBLOCK_EVENTS[event]["name"]} is already running.\n' estimate = await get_event_estimate_time( SKYBLOCK_EVENTS[event]['endpoint'], session=self.bot.http_session) if estimate is None or estimate < (current_milli_time() + (300 * 1000)): time = (current_milli_time() / 1000.0) + 1200 time = datetime.fromtimestamp(time) # Schedule in 20 mins to get new estimate event_data = { 'name': event, 'task_id': id(time), 'type': 'get_estimate', 'estimate': estimate, 'time': time } self._schedule_event_task(event_data) else: # Calculate when to alert event (5 mins before event starts) time = datetime.fromtimestamp((estimate / 1000.0) - 300.0) event_data = { 'name': event, 'task_id': id(time), 'type': 'alert', 'estimate': estimate, 'time': time } self._schedule_event_task(event_data) return f'{SKYBLOCK_EVENTS[event]["name"]} has been successfully started.\n'
def __init__(self, player: 'Player', call_back: Callable[[bool, int], NoReturn], is_death: bool = False): super().__init__(player) self.is_death = is_death self.call_back = call_back self.selected = 0 self.action_selected = -1 # self.arrow = utils.get_part_i(MENU_IMAGE, (0, 64, 22, 91), (33, 41)) self.arrow = utils.ARROW self.open_time = utils.current_milli_time() self.text_2 = [(game.FONT_20.render(game.get_game_instance().get_message(t), True, (0, 0, 0)), game.FONT_20.render(game.get_game_instance().get_message(t), True, (255, 255, 255))) for t in (["use", "back"] if is_death else ["use", "heal", "back"])]
def tokenize_and_predict(sample, model_name): if model_name == "squad": model = squad_model tokenizer = base_tokenizer elif model_name == "hotpot": model = hotpot_model tokenizer = large_tokenizer elif model_name == "babi": model = babi_model tokenizer = base_tokenizer else: raise Exception example = read_squad_example(sample) input_features = tokenize(example, tokenizer) with torch.no_grad(): inputs = {'input_ids': input_features.input_ids, 'attention_mask': input_features.input_mask, 'token_type_ids': input_features.segment_ids } start_time = current_milli_time() # Make Prediction output = model(**inputs) end_time = current_milli_time() logger.info("Prediction Time: {} ms".format(end_time - start_time)) # Parse Prediction prediction, hidden_states = parse_model_output(output, example, input_features) logger.info("Predicted Answer: {}".format(prediction["text"])) logger.info("Start token: {}, End token: {}".format(prediction["start_index"], prediction["end_index"])) return prediction, hidden_states, input_features
def getSpeech(self, parameters, data): now = current_milli_time() aWeekAgo = now - 604800000L sessionsFromLastWeek = [ session for session in data["session"] if long(session["startTimeMillis"]) > aWeekAgo ] totalTime = sum([ long(session["endTimeMillis"]) - long(session["startTimeMillis"]) for session in sessionsFromLastWeek ]) totalTimeMinutes = totalTime / 1000 / 60 return "This past week you worked out for a total of " + str( totalTimeMinutes) + " minutes"
def socket_to_file(port, filename): host = "0.0.0.0" s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) s.bind((host, port)) f = open(filename, 'wb') try: data, addr = s.recvfrom(buffer_size) last_time = current_milli_time() while data: # print "Received Data" if len(data) >= buffer_size: print "Received Data of buffer size(!), increase buffer size" data_file.add_packet(f, current_milli_time() - last_time, data) last_time = current_milli_time() s.settimeout(None) data, addr = s.recvfrom(buffer_size) except socket.timeout: f.close() s.close() print "Socket Error"
def __init__(self, x, y, speed, color, width, height, direction, horizontal, max_health_points, immortal=False, collision_behavior=utils.DO_NOT_IGNORE, sprite="data/sprites/thread.png"): global g_id self.id = g_id g_id += 1 screen = pygame.display.get_surface() self.speed = speed self.color = color self.direction = direction self.horizontal = horizontal self.collision_behavior = collision_behavior self.immortal = immortal self.invencible = False self.invencible_duration = utils.current_milli_time() self.invencible_switch_color = self.color self.move_pos = [0, 0] self.health_points = max_health_points self.max_health_points = max_health_points pygame.sprite.Sprite.__init__(self) self.image = pygame.image.load(sprite).convert_alpha() self.image = pygame.transform.scale(self.image, (width, height)) self.rect = self.image.get_rect() self.area = screen.get_rect() self.mask = pygame.mask.from_surface(self.image) g_game.objects[self.id] = self g_game.sprite_group.add(self) self.teleport(x, y)