def render(self): read_game = self.env.read_game frame = self.env.frame if not read_game.is_in_game or not keys["KEY_RADAR"]: return rx = self.rx = int(read_game.resolution_x / 2 - RADAR_SIZE / 2 + RADAR_CENTER_X) ry = self.ry = RADAR_OFFSET rh = rw = self.rh = self.rw = RADAR_SIZE r = D3DRECT(rx, ry, rx + rw, ry + rh) frame.device.Clear(1, byref(r), D3DCLEAR.TARGET, MAP_COLOR_BACK, 1, 0) draw4(frame.line, rx, ry, rx + rw, ry, rx + rw, ry + rh, rx, ry + rh, 2, MAP_COLOR_BORDER) draw_arrow(frame.line, rx + rw / 2, ry + rh / 2, 0, MAP_COLOR_ME) # myself for p in read_game.player: if p != read_game.my_player and p.type == ET_PLAYER and p.valid and p.alive & ALIVE_FLAG: cx, cy = self.calcPoint(p.pos, RADAR_RANGE) draw_arrow(frame.line, cx, cy, -p.yaw + read_game.view_angles.y, p.color_map) # clibrating is a debug mode if CALIBRATING: origin = VECTOR(0, 0, 0) cx, cy = self.calcPoint(origin, RADAR_RANGE) draw_spot(frame.line, cx, cy, 0x7FFFFFFF)
def __getitem__(self, index): data_dict = {} idx_seq = index // self.data_per_seq idx_step = index % self.data_per_seq * self.seq_len for step_id in range(self.seq_len): f = h5py.File( osp.join( self.data_path, "%s_%d.hdf5" % (self.idx_list[idx_seq], idx_step + step_id)), "r") # action action = f['action'] data_dict['%d-action' % step_id] = self.get_action(action) # color_image, [W, H, 3] if 'color_image' in self.returns: data_dict['%d-color_image' % step_id] = np.asarray( f['color_image_small'], dtype=np.uint8) # color_heightmap, [128, 128, 3] if 'color_heightmap' in self.returns: # draw arrow for visualization color_heightmap = draw_arrow( np.asarray(f['color_heightmap'], dtype=np.uint8), (int(action[2]), int(action[1]), int(action[0]))) data_dict['%d-color_heightmap' % step_id] = color_heightmap # tsdf, [S1, S2, S3] if 'tsdf' in self.returns: data_dict['%d-tsdf' % step_id] = np.asarray(f['tsdf'], dtype=np.float32) # mask_3d, [S1, S2, S3] if 'mask_3d' in self.returns: data_dict['%d-mask_3d' % step_id] = np.asarray(f['mask_3d'], dtype=np.int) # scene_flow_3d, [3, S1, S2, S3] if 'scene_flow_3d' in self.returns: scene_flow_3d = np.asarray(f['scene_flow_3d'], dtype=np.float32).transpose( [3, 0, 1, 2]) data_dict['%d-scene_flow_3d' % step_id] = scene_flow_3d return data_dict
def render(self, display: pygame.Surface): display.fill("#ecdcdf") pygame.draw.polygon(display, "#f4523b", PokeDexInfo.poly_1) pygame.draw.polygon(display, "#fa7248", PokeDexInfo.poly_2) pygame.draw.polygon(display, "#f4523b", PokeDexInfo.poly_3) utils.draw_button_info(display, **self.keys) poke = pokemon.get_pokemon(self.selected + 1) # big big_im = displayer.get_poke(PokeDex.PATH(str(poke.id_)), 3) s_x, s_y = big_im.get_size() display.blit(big_im, (250 - s_x // 2, 300 - s_y // 2)) utils.draw_split_rectangle(display, (477, 60, 530, 50), 0.4, 0.35, "#f0501e", "#000000") utils.draw_arrow(display, True, 742, 56, (255, 255, 255), size=2) utils.draw_arrow(display, False, 742, 114, (255, 255, 255), size=2) y = 62 im = displayer.get_poke(PokeDex.PATH(str(poke.id_)), 0.7) delta_x, delta_y = utils.get_first_color(im) x = 480 display.blit(im, (x, y + 30 - delta_y)) status = game.get_game_instance().get_pokedex_status(self.selected + 1) display.blit(game.FONT_24.render(f"N° {pokemon.to_3_digit(self.selected + 1)}", True, (255, 255, 255)), (x + 50, y + 10)) display.blit(game.FONT_24.render(poke.get_name(True) if poke.id_ != 0 else "???", True, (255, 255, 255)), (689, y + 10)) if status != game.POKEDEX_NEVER_SEEN: display.blit( self.white_pokeball if status == game.POKEDEX_CATCH else utils.POINT_POKEBALL, (950, y + 8) ) x, y = 530, 150 l = 424 h = 40 s = 3 pygame.draw.rect(display, "#dbdbd9", (x, y, l, h,)) display.blit(tx := game.FONT_24.render(poke.get_japan_name(), True, (0, 0, 0)), (x + (l - tx.get_size()[0]) // 2, y + (h - tx.get_size()[1]) // 2)) y += h + s tx = ("type", "size", "weight", "view") tx2 = (None, f'{poke.size} m', f'{poke.weight} Kg', str(game.get_game_instance().get_nb_view(self.selected + 1))) for i in range(4): pygame.draw.rect(display, "#dbdbd9", (x, y, l // 2, h)) pygame.draw.rect(display, "#ffffff", (x + l // 2, y, l // 2, h)) display.blit(sur := game.FONT_24.render(game.get_game_instance().get_message(tx[i]), True, (0, 0, 0)), utils.get_center(sur, (x, y, l // 2, h))) if i != 0: display.blit(sur := game.FONT_24.render(tx2[i], True, (0, 0, 0)), utils.get_center(sur, (x + l // 2 + 5, y, l // 2, h), center_x=False)) else: _x_ = x + l // 2 + 10 for ii in range(len(poke.types)): utils.draw_type(display, _x_, y + h // 2 - 8, poke.types[ii]) _x_ += 106 y += h if i != 3: pygame.draw.rect(display, "#d2d2d2", (x, y, l // 2, s)) pygame.draw.rect(display, "#f3f3f3", (x + l // 2, y, l // 2, h)) y += s pygame.draw.rect(display, "#ffffff", (x, y, l, int(h * 4.5))) x += 5 y += 10 for p_l in hud.Dialog.split(poke.get_pokedex(), 40): display.blit(game.FONT_20.render(p_l, True, (0, 0, 0)), (x, y)) y += game.FONT_SIZE_20[1] + 5
def render(self): read_game = self.env.read_game frame = self.env.frame textures = self.env.textures if not read_game.is_in_game or not keys["KEY_BIG_RADAR"]: return map_name = read_game.map_name if map_name not in textures.textures: print "map: %s not found" % map_name return rx = self.rx = read_game.resolution_x - RADAR_OFFSET - 512*self.scaling ry = self.rx = RADAR_OFFSET rh = self.rh = 512*self.scaling rw = self.rw = 512*self.scaling sprite_center = D3DXVECTOR2(0, 0) trans = D3DXVECTOR2(rx, ry) matrix = D3DMATRIX() d3dxdll.D3DXMatrixAffineTransformation2D(byref(matrix), #@UndefinedVariable c_float(self.scaling), # scaling byref(sprite_center), # rotation center c_float(0), # angle byref(trans) # translation ) frame.sprite.Begin(0) frame.sprite.SetTransform(matrix) frame.sprite.Draw(textures.textures[map_name], None, None, None, BIG_RADAR_BLENDING) frame.sprite.End() matrix = textures.matrix[map_name] transl = textures.translations[map_name] map_pos = VECTOR() arrow_angle = textures.angle[map_name] arrow_inversion = textures.angle_inversion[map_name] for te in self.env.tracker.get_tracked_entity_list(): x = self.scaling * (transl[0] + matrix[0]*te.pos.x + matrix[1]*te.pos.y) y = self.scaling * (transl[1] + matrix[2]*te.pos.x + matrix[3]*te.pos.y) if x < 0: x = 0 if x > rw: x = rw if y < 0: y = 0 if y > rh: y = rh if te.type == ET_TURRET: self.env.sprites.draw_sentry(rx + x, ry + y, te.planter.enemy) if te.type == ET_HELICOPTER: self.env.sprites.draw_heli(rx + x, ry + y, -te.yaw + arrow_angle + arrow_inversion, te.planter.enemy, te.weapon_num) if te.type == ET_PLANE: self.env.sprites.draw_plane(rx + x, ry + y, -te.yaw + arrow_angle + arrow_inversion, te.planter.enemy) if te.type == ET_EXPLOSIVE and te.model_name.find("_AIRDROP_") > 0: self.env.sprites.draw_flare(rx + x, ry + y) pos = read_game.mw2_mypos map_pos.x = self.scaling * (transl[0] + matrix[0]*pos.x + matrix[1]*pos.y) map_pos.y = self.scaling * (transl[1] + matrix[2]*pos.x + matrix[3]*pos.y) draw_arrow(frame.line, rx + map_pos.x, ry + map_pos.y, -read_game.view_angles.y + arrow_angle, MAP_COLOR_ME); # myself for p in read_game.player: if p != read_game.my_player and p.type == ET_PLAYER and p.valid and p.alive & ALIVE_FLAG: map_pos.x = self.scaling * (transl[0] + matrix[0]*p.pos.x + matrix[1]*p.pos.y) map_pos.y = self.scaling * (transl[1] + matrix[2]*p.pos.x + matrix[3]*p.pos.y) draw_arrow(frame.line, rx + map_pos.x, ry + map_pos.y, -p.yaw + arrow_angle + arrow_inversion, p.color_map); # myself
def render(self): read_game = self.env.read_game frame = self.env.frame textures = self.env.textures if not read_game.is_in_game or not keys["KEY_RADAR"]: return rx = self.rx = int(read_game.resolution_x/2 - RADAR_SIZE/2 + RADAR_CENTER_X) ry = self.ry = RADAR_OFFSET rh = rw = self.rh = self.rw = RADAR_SIZE scaling = 0.5 # TODO pos = read_game.mw2_mypos map_name = read_game.map_name # name of the current map p_matrix = textures.matrix[map_name] # transformation matrix (scale + rotation) transl = textures.translations[map_name] # translation vector to correct with map origin map_pos = VECTOR() # contains the coord on the map (with applied scaling) map_pos.x = scaling * (transl[0] + p_matrix[0]*pos.x + p_matrix[1]*pos.y) map_pos.y = scaling * (transl[1] + p_matrix[2]*pos.x + p_matrix[3]*pos.y) arrow_angle = textures.angle[map_name] # offset to apply to angles (only in estate)s arrow_inversion = textures.angle_inversion[map_name] sprite_center = D3DXVECTOR2(map_pos.x, map_pos.y) trans = D3DXVECTOR2(rx + rw/2 - map_pos.x, ry + rh/2 - map_pos.y) # global translation #print "x=%.2f y=%.2f" % (new_pos.x, new_pos.y ) angle = radians(read_game.view_angles.y - arrow_angle) matrix = D3DMATRIX() d3dxdll.D3DXMatrixAffineTransformation2D(byref(matrix), #@UndefinedVariable c_float(scaling), # scaling byref(sprite_center), # rotation center c_float(angle), # angle byref(trans) # translation ) r = D3DRECT(rx, ry, rx + rw, ry + rh) frame.device.Clear(1, byref(r), D3DCLEAR.TARGET, MAP_COLOR_BACK, 1, 0) if keys["KEY_RADAR_MAP"]: frame.device.SetRenderState(174, True) save_scissors = None try: save_scissors = RECT() frame.device.GetScissorRect(byref(save_scissors)) scissors = RECT(rx, ry, rx+rw, ry+rh) frame.device.SetScissorRect(byref(scissors)) except: pass frame.sprite.Begin(0) frame.sprite.SetTransform(matrix) frame.sprite.Draw(textures.textures[map_name], None, None, None, BIG_RADAR_BLENDING) frame.sprite.Flush() frame.sprite.End() frame.device.SetRenderState(174, False) if not save_scissors is None: frame.device.SetScissorRect(byref(save_scissors)) draw4(frame.line, rx, ry, rx+rw, ry, rx+rw, ry+rh, rx, ry+rh, 2, MAP_COLOR_BORDER) p_pos = VECTOR() for te in self.env.tracker.get_tracked_entity_list(): p_pos.x = transl[0] + p_matrix[0]*te.pos.x + p_matrix[1]*te.pos.y p_pos.y = transl[1] + p_matrix[2]*te.pos.x + p_matrix[3]*te.pos.y cx, cy = self.calcPoint(p_pos, matrix) if te.type == ET_TURRET: self.env.sprites.draw_sentry(cx, cy, te.planter.enemy) if te.type == ET_HELICOPTER: self.env.sprites.draw_heli(cx, cy, -te.yaw + read_game.view_angles.y + arrow_angle + arrow_inversion, te.planter.enemy, te.weapon_num) if te.type == ET_PLANE: self.env.sprites.draw_plane(cx, cy, -te.yaw + read_game.view_angles.y + arrow_angle + arrow_inversion, te.planter.enemy) if te.type == ET_EXPLOSIVE and te.model_name.find("_AIRDROP_") > 0: self.env.sprites.draw_flare(cx, cy) draw_arrow(frame.line, rx + rw/2, ry + rh/2, 0, MAP_COLOR_ME); # myself for p in read_game.player: if p != read_game.my_player and p.type == ET_PLAYER and p.valid and p.alive & ALIVE_FLAG: p_pos.x = transl[0] + p_matrix[0]*p.pos.x + p_matrix[1]*p.pos.y p_pos.y = transl[1] + p_matrix[2]*p.pos.x + p_matrix[3]*p.pos.y cx, cy = self.calcPoint(p_pos, matrix) draw_arrow(frame.line, cx, cy, -p.yaw + read_game.view_angles.y + arrow_angle + arrow_inversion, p.color_map);