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);