📄 modmain.bas
字号:
Call DrawBufToView
DoEvents
While IsPlaying And Abs(timeGetTime - KT) < 35 ' 20 '''20 ''' 28帧' 暂时用 50帧 调试
DoEvents ''debug
Wend
Loop
If IsUnloadAll Then Unload FrmMain '可能为程序结束的最后一个过程
''加上一个unload frmmain的理由,请看
''Frmmain的form_load过程开始
''事实上如果frmmain之前已经卸载,并不会运行form_unload过程
''所以并没什么影响
End Sub
Public Function TestAllObject() As Boolean
Dim TA As Integer
For TA = 1 To MaxObj
If PlayObj(TA).IndexR > 0 Then TestAllObject = True: Exit Function
Next TA
For TA = 1 To MaxSta
If PlaySta(TA).IndexR > 0 Then TestAllObject = True: Exit Function
Next TA
TestAllObject = False
End Function
Public Sub InsertPlay()
Static InFps As Long
'If InFps > 200 Then Exit Sub
InFps = InFps + 1
Select Case InFps
Case 1
FrmMain.PicCover.BackColor = FrmMain.BackColor
FrmMain.PicCover.Visible = True
FrmMain.PicCover.Move 0, 0, 640, 0
Case Is < 97
FrmMain.PicCover.Height = InFps * 5
Case 97
Call UnloadRunObject
Call FrmMain.LoadMap
Case Is < 194
FrmMain.PicCover.Height = (194 - InFps) * 5
Case 195
FrmMain.PicCover.Visible = False
InFps = 0
IsShowInsertPlay = False
If CurOption.GMusic = 1 Then GameSound.PlayMusic LoadMusicList(Int(UBound(LoadMusicList) * Rnd) + 1)
End Select
End Sub
Public Sub UnloadRunObject()
For N = 1 To MaxBackObj
PlayBackObj(N).IndexR = 0
Next
For N = 1 To MaxBul
PlayBul(N).IndexR = 0
Next
For N = 1 To MaxMyBul
PlayMyBul(N).IndexR = 0
Next
For N = 1 To MaxTail
BulTail(N).ColorTail = 0
Next
End Sub
Public Sub LoadMapObject()
Dim MapI As Integer
Static LastSeat As Integer
If CurMapSeat > 2 Then
'If MapSpeed = 0.5 Then
CurMapSeat = CurMapSeat - MapSpeed ' 1 '
'Else
'CurMapSeat = CurMapSeat - Int(MapSpeed)
'End If
ElseIf Not TestAllObject Then
IsShowInsertPlay = True
'debug speed
'If CurMapSeat <= 2 Then MsgBox "游戏暂时到此": IsPlaying = False
End If
If IsShowInsertPlay Then Call InsertPlay
If Int(CurMapSeat) <> LastSeat Then
CurMapSeatObj = Int(CurMapSeat) '*****************
LastSeat = CurMapSeatObj
Else
Exit Sub
End If
'''''
'Debug.Print CurMapSeatObj
'If CurMapSeatObj = 5769 Then Stop
If CurMapSeatObj Mod 20 = 0 Then
'Stop '****************************************
MapI = CurMapSeatObj \ 20 ''CurMapSeatObj的最小值为20 ,否则会出错,所以必须限制不能=0
For CountA = 1 To 40
If Map.ObjMap(MapI).SingleObj(CountA).IsUsed = 0 Then Exit For
Select Case Map.ObjMap(MapI).SingleObj(CountA).TypeObj
Case 0
For CountB = CurObj + 1 To MaxObj
If PlayObj(CountB).IndexR = 0 Then
With PlayObj(CountB)
.IndexR = Map.ObjMap(MapI).SingleObj(CountA).IndexOjb
.CurX = Map.ObjMap(MapI).SingleObj(CountA).SeatX
.CurY = -LoadObj(.IndexR).Height '决定于物体高度
.StartX = .CurX
.StartY = .CurY
.MoveType = Map.ObjMap(MapI).SingleObj(CountA).MoveType
.PackageType = Map.ObjMap(MapI).SingleObj(CountA).IsPac
'.IsCanExit = 0
.CurSpeedX = 0
.CurSpeedY = 0 '在draw时才利用movepath修改
.CurAngle = 90 ' Rnd * 360 90度为标准状态
.BasSpeed = Rnd * 2 + 2
.BasAngle = Sgn(Rnd * 2 - 1.05) * (Rnd * 4 + 1) '顺逆时针取向 和 随机路径
.CurFps = 1
.CurDelay = 0
.CurTotFps = 1
.CurFireFps(1) = 0
.CurFireFps(2) = 0
.CurFireFps(3) = 0
.DelayFps = LoadObj(.IndexR).DelayFps
.CurLife = LoadObj(.IndexR).Life
If Not IsLoadP(1) Then
.FollowPlayer = 2
ElseIf Not IsLoadP(2) Then
.FollowPlayer = 1
Else
.FollowPlayer = 1 + Int(Rnd * 2)
End If
End With
CurObj = CountB: Exit For ''''''''''''''
End If
Next CountB
Case 1
For CountB = CurSta + 1 To MaxSta
If PlaySta(CountB).IndexR = 0 Then
With PlaySta(CountB)
.IndexR = Map.ObjMap(MapI).SingleObj(CountA).IndexOjb
.CurX = Map.ObjMap(MapI).SingleObj(CountA).SeatX
.CurY = -LoadSta(.IndexR).Height
.StartX = .CurX
.StartY = .CurY
.MoveType = Map.ObjMap(MapI).SingleObj(CountA).MoveType
.PackageType = Map.ObjMap(MapI).SingleObj(CountA).IsPac
'.IsCanExit = 0
.CurSpeedX = 0
.CurSpeedY = 0
.CurAngle = 90 ' Rnd * 360 ''' 90 '
.BasSpeed = Rnd * 4 + 1
.BasAngle = Sgn(Rnd * 2 - 1.05) * (Rnd * 4 + 1) '顺逆时针取向 和 随机路径
.CurFps = 0
.CurDelay = 0
.CurTotFps = 0
.CurFireFps(1) = 0
.CurFireFps(2) = 0
.CurFireFps(3) = 0
.CurLife = LoadSta(.IndexR).Life
.RotateAngle = 0
If Not IsLoadP(1) Then
.FollowPlayer = 2
ElseIf Not IsLoadP(2) Then
.FollowPlayer = 1
Else
.FollowPlayer = 1 + Int(Rnd * 2)
End If
End With
CurSta = CountB: Exit For '''''''''''''
End If
Next CountB
'Case 3, 4, 5
Case 4
For CountB = CurBackObj + 1 To MaxBackObj
If PlayBackObj(CountB).IndexR = 0 Then
With PlayBackObj(CountB)
.IndexR = Map.ObjMap(MapI).SingleObj(CountA).IndexOjb
.CurX = Map.ObjMap(MapI).SingleObj(CountA).SeatX
.CurY = -LoadBackObj(.IndexR).Height
.CurSpeedY = Map.HeadMapFile.SpeedMap
.CurTotFps = 0
.CurFps = 0
.CurDelay = 0
End With
CurBackObj = CountB: Exit For
End If
Next CountB
Case Else: Exit Sub
End Select
Next CountA
End If
End Sub
'***********************************************************
Public Sub MoveMap()
'
'注意该处只作为作背景,物体不需要缓冲(轮换画)
End Sub
'**********************以下是draw ,是启动的主要部分
Public Sub DrawObject()
On Error Resume Next
For CountA = 1 To MaxObj
If PlayObj(CountA).IndexR > 0 Then
Call BltToBuf(LoadObj(PlayObj(CountA).IndexR).HdcE, LoadObj(PlayObj(CountA).IndexR).HdcBack, PlayObj(CountA).CurX, PlayObj(CountA).CurY, LoadObj(PlayObj(CountA).IndexR).Width, LoadObj(PlayObj(CountA).IndexR).Height, (PlayObj(CountA).CurFps - 1) * LoadObj(PlayObj(CountA).IndexR).Width, 0)
PlayObj(CountA).CurDelay = (PlayObj(CountA).CurDelay + 1) Mod LoadObj(PlayObj(CountA).IndexR).DelayFps
If PlayObj(CountA).CurDelay = 0 Then PlayObj(CountA).CurFps = PlayObj(CountA).CurFps Mod LoadObj(PlayObj(CountA).IndexR).AllFps + 1
If Not IsPaused Then PlayObj(CountA).CurTotFps = PlayObj(CountA).CurTotFps + 1
If PlayObj(CountA).CurY < 300 And Not IsPaused Then Call SetObjBullet(PlayObj(CountA), LoadObj(PlayObj(CountA).IndexR))
Call PathAll(PlayObj(CountA).StartX, PlayObj(CountA).StartY, PlayObj(CountA).CurX, PlayObj(CountA).CurY, PlayObj(CountA).CurSpeedX, PlayObj(CountA).CurSpeedY, PlayObj(CountA).CurAngle, PlayObj(CountA).MoveType, PlayObj(CountA).BasSpeed, PlayObj(CountA).BasAngle, PlayObj(CountA).CurTotFps)
'pathall 即是moveobject
Call CrashObjMybul(PlayObj(CountA), LoadObj(PlayObj(CountA).IndexR))
Call CrashObjPla(PlayObj(CountA)) '该两项并列,都可以 resetobject
Call ReSetObject(PlayObj(CountA))
End If
Next CountA
End Sub
Public Sub DrawBackObject()
On Error Resume Next
For CountA = 1 To MaxBackObj
If PlayBackObj(CountA).IndexR > 0 Then
Call BltToBuf(LoadBackObj(PlayBackObj(CountA).IndexR).HdcE, LoadBackObj(PlayBackObj(CountA).IndexR).HdcBack, PlayBackObj(CountA).CurX, PlayBackObj(CountA).CurY, LoadBackObj(PlayBackObj(CountA).IndexR).Width, LoadBackObj(PlayBackObj(CountA).IndexR).Height, (PlayBackObj(CountA).CurFps - 1) * LoadBackObj(PlayBackObj(CountA).IndexR).Width, 0)
PlayBackObj(CountA).CurDelay = (PlayBackObj(CountA).CurDelay + 1) Mod LoadBackObj(PlayBackObj(CountA).IndexR).DelayFps
If PlayBackObj(CountA).CurDelay = 0 Then PlayBackObj(CountA).CurFps = PlayBackObj(CountA).CurFps Mod LoadBackObj(PlayBackObj(CountA).IndexR).AllFps + 1
If Not IsPaused Then
PlayBackObj(CountA).CurTotFps = PlayBackObj(CountA).CurTotFps + 1
Select Case PlayBackObj(CountA).CurSpeedY
Case 1
If GameFps Mod 4 = 0 Then PlayBackObj(CountA).CurY = PlayBackObj(CountA).CurY + 1
Case 2
If GameFps Mod 2 = 0 Then PlayBackObj(CountA).CurY = PlayBackObj(CountA).CurY + 1
Case 4
PlayBackObj(CountA).CurY = PlayBackObj(CountA).CurY + 1
Case 8
PlayBackObj(CountA).CurY = PlayBackObj(CountA).CurY + 2
End Select
End If
'If PlayBackObj(CountA).CurTotFps Mod 2 <> 0 Then
'If Not IsPaused Then PlayBackObj(CountA).CurY = PlayBackObj(CountA).CurY + PlayBackObj(CountA).CurSpeedY
'If ((MapSpeed = 0.5) And (Jk Mod 2 <> 0)) Or MapSpeed <> 0.5 Then
'End If
If PlayBackObj(CountA).CurY >= 484 Then PlayBackObj(CountA).IndexR = 0
End If
Next CountA
End Sub
Public Sub DrawStaticObject()
Dim CStaSeat As Integer
For CountA = 1 To MaxSta
If PlaySta(CountA).IndexR > 0 Then
If LoadSta(PlaySta(CountA).IndexR).IsRotate Then
PlaySta(CountA).CurAutoAngle = GetAngle(PlaySta(CountA).CurX, PlaySta(CountA).CurY, PlaySta(CountA).FollowPlayer)
'If RunEffect = 2 Then
' CStaSeat = ((PlaySta(CountA).CurAutoAngle + 720) Mod 360) \ 10
' CStaSeat = CStaSeat * LoadSta(PlaySta(CountA).IndexR).RotateWidth
'
' Call BltToBuf(LoadSta(PlaySta(CountA).IndexR).HdcE, LoadSta(PlaySta(CountA).IndexR).HdcBack, PlaySta(CountA).CurX, PlaySta(CountA).CurY, CSng(LoadSta(PlaySta(CountA).IndexR).RotateWidth), CSng(LoadSta(PlaySta(CountA).IndexR).RotateWidth), CSng(CStaSeat))
'Else
Call RotateToBuf(LoadSta(PlaySta(CountA).IndexR).HdcE, LoadSta(PlaySta(CountA).IndexR).HdcBack, PlaySta(CountA).CurX, PlaySta(CountA).CurY, LoadSta(PlaySta(CountA).IndexR).Width, LoadSta(PlaySta(CountA).IndexR).Height, PlaySta(CountA).CurAutoAngle, LoadSta(PlaySta(CountA).IndexR).MaskColor, CSng(LoadSta(PlaySta(CountA).IndexR).RotateWidth))
'End If
ElseIf LoadSta(PlaySta(CountA).IndexR).IsFlick Then
PlaySta(CountA).CurAutoAngle = (PlaySta(CountA).CurAutoAngle + LoadSta(PlaySta(CountA).IndexR).IsFlick) Mod 360
'If RunEffect = 2 Then
' CStaSeat = ((PlaySta(CountA).CurAutoAngle + 720) Mod 360) \ 10
' CStaSeat = CStaSeat * LoadSta(PlaySta(CountA).IndexR).RotateWidth
' Call BltToBuf(LoadSta(PlaySta(CountA).IndexR).HdcE, LoadSta(PlaySta(CountA).IndexR).HdcBack, PlaySta(CountA).CurX, PlaySta(CountA).CurY, CSng(LoadSta(PlaySta(CountA).IndexR).RotateWidth), CSng(LoadSta(PlaySta(CountA).IndexR).RotateWidth), CSng(CStaSeat))
'Else
Call RotateToBuf(LoadSta(PlaySta(CountA).IndexR).HdcE, LoadSta(PlaySta(CountA).IndexR).HdcBack, PlaySta(CountA).CurX, PlaySta(CountA).CurY, LoadSta(PlaySta(CountA).IndexR).Width, LoadSta(PlaySta(CountA).IndexR).Height, PlaySta(CountA).CurAutoAngle, LoadSta(PlaySta(CountA).IndexR).MaskColor, CSng(LoadSta(PlaySta(CountA).IndexR).RotateWidth))
'End If
Else
Call BltToBuf(LoadSta(PlaySta(CountA).IndexR).HdcE, LoadSta(PlaySta(CountA).IndexR).HdcBack, PlaySta(CountA).CurX, PlaySta(CountA).CurY, LoadSta(PlaySta(CountA).IndexR).Width, LoadSta(PlaySta(CountA).IndexR).Height)
End If
''''PlaySta(CountA).CurFps = (PlaySta(CountA).CurFps + 1) Mod LoadSta(PlaySta(CountA).IndexR)
''''PlaySta(CountA).CurDelay
If Not IsPaused Then PlaySta(CountA).CurTotFps = PlaySta(CountA).CurTotFps + 1 ' 计量 bullet
',mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
If PlaySta(CountA).CurY < 300 And (Not IsPaused) Then Call SetStaBullet(PlaySta(CountA), LoadSta(PlaySta(CountA).IndexR))
Call PathAll(PlaySta(CountA).StartX, PlaySta(CountA).StartY, PlaySta(CountA).CurX, PlaySta(CountA).CurY, PlaySta(CountA).CurSpeedX, PlaySta(CountA).CurSpeedY, PlaySta(CountA).CurAngle, PlaySta(CountA).MoveType, PlaySta(CountA).BasSpeed, PlaySta(CountA).BasAngle, PlaySta(CountA).CurTotFps)
'pathall 即是moveStaticObj
Call CrashStaMybul(PlaySta(CountA), LoadSta(PlaySta(CountA).IndexR))
Call CrashStaPla(PlaySta(CountA))
Call ReSetStaticObj(PlaySta(CountA))
End If
Next CountA
End Sub
Public Sub DrawPackage()
On Error Resume Next
For CountA = 1 To MaxPac
If PlayPac(CountA).IndexR > 0 Then
Call BltToBuf(LoadPac(PlayPac(CountA).IndexR).HdcE, LoadPac(PlayPac(CountA).IndexR).HdcBack, PlayPac(CountA).CurX, PlayPac(CountA).CurY, LoadPac(PlayPac(CountA).IndexR).Width, LoadPac(PlayPac(CountA).IndexR).Height, (PlayPac(CountA).CurFps - 1) * LoadPac(PlayPac(CountA).IndexR).Width, 0)
With PlayPac(CountA)
'If Abs(.CurX + .CurSpeedX - MidX) > MidX - 40 And .CurTotalFps <= 1000 Then .CurSpeedX = -.CurSpeedX
'If Abs(.CurY + .CurSpeedY - MidY) > MidY - 40 And .CurTotalFps <= 1000 Then .CurSpeedY = -.CurSpeedY
.CurX = .CurX + .CurSpeedX
.CurY = .CurY + .CurSpeedY
.CurDelay = (.CurDelay + 1) Mod LoadPac(.IndexR).DelayFps
If .CurTotalFps <= 1000 Then
If .CurX < 40 Then
.CurSpeedX = 2
ElseIf .CurX > Map.HeadMapFile.WidthShow Then
.CurSpeedX = -2
End If
If .CurY < 40 Then
.CurSpeedY = 2
ElseIf .CurY > 440 Then
.CurSpeedY = -2
End If
End If
If .CurDelay = 0 Then .CurFps = .CurFps Mod LoadPac(.IndexR).AllFps + 1
If Not IsPaused Then .CurTotalFps = .CurTotalFps + 1
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -