自己整了4个目标用于扫描。以后可能可以自己添加删除(写到这儿忽然觉得C++的vector不能删除元素(反正C++ Primer里目前没找到)让人很郁闷)
Form1,须加一个Timer1
Dim CAngle As Integer 'Current Angle (Not Class Angle) Private Sub Form_Load() '初始化 CAngle = 0 Me.BackColor = vbBlack Me.BorderStyle = 3 Me.FillColor = vbYellow Me.ForeColor = vbGreen Me.FillStyle = 1 Me.ScaleMode = 3 'Pixel Me.Width = 4590 Me.Height = 4980 Timer1.Interval = 10 End Sub Private Sub Timer1_Timer() Cls Circle (150,150),130 If CAngle = 359 Then CAngle = 0 Else CAngle = CAngle + 1 Raida CAngle '绘制雷达 RaidaTarget 0.5,20 '定义雷达目标1 RaidaTarget 0.7,200 '定义雷达目标2 RaidaTarget 0.2,100 '定义雷达目标3 RaidaTarget 0.9,257 '定义雷达目标4 End Sub Private Sub Raida(ByVal angle As Integer) '根据所给角度绘制雷达 Dim x As Single,y As Single,a As Single,_ ae As Single,g As Integer g = 0 ae = angle - 45 For a = ae To angle x = Cos(D2R(a)) * 130 + 150 y = Sin(D2R(a)) * 130 + 150 g = (a - ae) / 20 * 255 Line (150,150)-(x,y),RGB(0,g,0) Next a End Sub Private Sub RaidaTarget(ByVal Row As Single,ByVal Thita As Integer) '根据雷达扫描区域绘制目标 Dim x As Integer,y As Integer x = Cos(D2R(Thita)) * Row * 130 + 150 y = Sin(D2R(Thita)) * Row * 130 + 150 Form1.FillStyle = 0 If Me.Point(x,y) <> 0 Then Circle (x,5,RGB(255,255,0) '如果雷达扫到目标则显示 Form1.FillStyle = 1 End Sub
Module1
Public Function D2R(ByVal d As Integer) As Single D2R = CDbl(d) * (3.14159265359 / 180) End Function '貌似没必要专门弄一个模块去装这么一个小东西