📄 pathtype.bas
字号:
Attribute VB_Name = "ModPathType"
Option Explicit
''''***********所有的位置和速度都由以下函数更改'is AimSeatX, AimSeatY
Public CurMyXp(1 To 2) As Single '当前飞机位置
Public CurMyYp(1 To 2) As Single '以(中点)记
Public CurMyFpsP(1 To 2) As Single
'**********
Public CurScrX As Single
Public CurScrY As Single ''=0
Public CurScrH As Single ''=480
'Public BasSpeed As Single '注意,必须 >=2 '基本速度 =4
'Public BasAngle As Byte '同上 =6
Public StaFps As Integer '''对于静止的动画的基本高度
''''''''''''''''''''''''''''''Sx and Sy are basic seat
''''''''''''''''''''''''''''''Sx and Sy 是地图上存储的位置,此时 Sx 相对屏幕不变,但Sy 会变
Public Function PathAll(ByVal Sx As Integer, ByVal Sy As Integer, CurX As Single, CurY As Single, CSpeedX As Single, CSpeedY As Single, CAngle As Single, ByVal CurPathType As Byte, ByVal BasSpeed As Single, ByVal BasAngle As Integer, ByVal CurrentFps As Integer)
'Dim ExSpeed As Byte
'**在初始化Eobject 时,依据FireType 必须把CurFire设定为不同的角度,标准情况下都设定为 90 度
If CurPathType >= 8 Then
If CurrentFps Mod 48 = 0 Then CurPathType = Int(Rnd * 8) '0 5 '' =''' '''''''''''其他值可得到不同的路径
End If
'CurPathType = 2
''''''''''''''''''''''''debug
Select Case CurPathType
Case 0
'直接向下移动'角度由 CAngle 定
CSpeedY = BasSpeed
CSpeedX = -Sgn(Sx - MidX) * Abs(CSpeedY * (CAngle Mod 91) / 100) ' 0
Case 1
'不做任何事,即静止于原处
CSpeedX = 0
If CurrentFps < StaFps Then CSpeedY = BasSpeed Else CSpeedY = 0
Case 2
'顺时针转,不移动
If CurrentFps < StaFps Then
CSpeedY = BasSpeed
Else
CAngle = (CAngle + BasAngle) Mod 360 '该角以角度制表示
CSpeedX = BasSpeed * Sin(CF(CAngle))
CSpeedY = Sgn(BasAngle) * BasSpeed * Cos(CF(CAngle))
End If
Case 3
'90 '顺时针转,向下移动 startAngle=90 度
If CurrentFps < StaFps Then
CSpeedY = BasSpeed
Else
CAngle = (CAngle + BasAngle) Mod 360 '该角以角度制表示
CSpeedX = BasSpeed * Sin(CF(CAngle))
CSpeedY = Sgn(BasAngle) * BasSpeed * Cos(CF(CAngle)) + BasSpeed \ 2
End If
Case 4
'旋转,横向运动
If CurrentFps < StaFps Then
CSpeedY = BasSpeed
Else
CAngle = (CAngle + BasAngle) Mod 360 '该角以角度制表示
CSpeedX = -BasSpeed * Sin(CF(CAngle))
CSpeedY = -BasSpeed * Cos(CF(CAngle))
CSpeedX = CSpeedX - Sgn(Sx - MidX \ 2) * BasSpeed \ 2
End If
Case 5
'90 '波浪线运行,纵向 startAngle=90 度
CAngle = (CAngle + BasAngle) Mod 360
CSpeedX = -BasSpeed * Sin(CF(CAngle))
CSpeedY = BasSpeed
Case 6
'波浪线运行,横向
If CurrentFps < StaFps Then
CSpeedY = BasSpeed
Else
CAngle = (CAngle + BasAngle) Mod 360
CSpeedY = -BasSpeed * Cos(CF(CAngle))
CSpeedX = -Sgn(Sx - MidX \ 2) * BasSpeed
End If
Case 7
'随机直线 方向不可预测
CAngle = CAngle + Rnd * BasAngle
If CAngle Mod 45 = 0 Then
CSpeedX = BasSpeed * (2 * Rnd - 1)
CSpeedY = BasSpeed * (2 * Rnd - 1)
End If
Case Is >= 8
'随机 路径不可预测
'该类型已被放到Select Case 之前
End Select
CurX = CurX + CSpeedX ' 注意:在此已经移动了
CurY = CurY + CSpeedY
End Function
Public Sub GetRotateAngle(RotAngle As Integer, ByVal Sx As Integer, ByVal Sy As Integer, Optional ByVal FollowPlayer As Byte, Optional ByVal FRotate As Boolean, Optional ByVal ARotate As Integer)
If FRotate Then
ElseIf ARotate Then
RotAngle = RotAngle + ARotate
RotAngle = IIf(RotAngle >= 360, RotAngle - 360, RotAngle)
End If
End Sub
Public Function CF(Anglex As Single) As Single
CF = Anglex * 3.14 / 180
End Function
Public Function GetAngle(ByVal SeatX As Single, ByVal SeatY As Single, ByVal WhPlayer As Byte) As Integer
Dim ErrorA As Integer
''''''''''''''''''''''''''''''''debug follow p1
'Dim WhPlayer As Byte
ErrorA = (CurMyYp(WhPlayer) - SeatY)
If ErrorA Then
GetAngle = -Atn((CurMyXp(WhPlayer) - SeatX) / ErrorA) * 180 / 3.14
Else
GetAngle = -90 * Sgn(CurMyXp(WhPlayer) - SeatX)
End If
If CurMyYp(WhPlayer) < SeatY Then GetAngle = GetAngle + 180
End Function
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -