?? modmybullet.bas
字號:
Attribute VB_Name = "ModMyBullet"
Option Explicit
Enum LOrR
LeftBul = 0
RightBul = 2
End Enum
'********************************* 把飛機的兩個位置分開算
Public Sub CreateMyBullet(ByVal WhPlayer As Byte, ByVal SeatX As Single, ByVal SeatY As Single, ByVal FireType As Byte, ByVal PowerStage As Byte, Optional ByVal LeftOrRight As LOrR) ' 0 or 2
Static Ang As Long
Static DL As Long
Dim Ind As Byte
Dim CountF As Long
For Ind = CurMyBul + 1 To MaxMyBul
If PlayMyBul(Ind).IndexR = 0 Then
Select Case FireType
Case 1 '散彈
Select Case PowerStage
Case 0, 1
With PlayMyBul(Ind)
.WhichPlayer = WhPlayer
.IndexR = 1
.MoveType = 2
.CurX = SeatX - LoadMyBul(1).Width \ 2
.CurY = SeatY - LoadMyBul(1).Height \ 2
.CurSpeedX = 0
.CurSpeedY = -15
.CurAngle = 0
'.CurDelay
End With
Case 2
With PlayMyBul(Ind)
.WhichPlayer = WhPlayer
.IndexR = 2
.MoveType = 1
.CurX = SeatX - LoadMyBul(2).Width \ 2 - (LeftOrRight - 1) * 4
.CurY = SeatY - LoadMyBul(2).Height \ 2
.CurSpeedX = 0
.CurSpeedY = -25
.CurAngle = 0
End With
'遞歸一次
Call CreateMyBullet(WhPlayer, SeatX, SeatY, 1, 1, LeftOrRight)
Case 3
With PlayMyBul(Ind)
.WhichPlayer = WhPlayer
.IndexR = 3
.MoveType = 1
.CurX = SeatX - LoadMyBul(3).Width \ 2
.CurY = SeatY - LoadMyBul(3).Height \ 2
.CurSpeedX = (LeftOrRight - 1) * 10
.CurSpeedY = -15
.CurAngle = 0
End With
Call CreateMyBullet(WhPlayer, SeatX, SeatY, 1, 2, LeftOrRight)
Case 4
With PlayMyBul(Ind)
.WhichPlayer = WhPlayer
.IndexR = 4
.MoveType = 1
.CurX = SeatX - LoadMyBul(4).Width \ 2
.CurY = SeatY - LoadMyBul(4).Height \ 2
.CurSpeedX = (LeftOrRight - 1) * 20
.CurSpeedY = -15
.CurAngle = 0
End With
Call CreateMyBullet(WhPlayer, SeatX, SeatY, 1, 3, LeftOrRight)
End Select
Exit For
Case 2
Select Case PowerStage
Case 0, 1
With PlayMyBul(Ind)
.WhichPlayer = WhPlayer
.IndexR = 5
.MoveType = 1
.CurX = SeatX - LoadMyBul(5).Width \ 2
.CurY = SeatY - LoadMyBul(5).Height \ 2
.CurSpeedX = 0
.CurSpeedY = -15
.CurAngle = 0
End With
Case 2
With PlayMyBul(Ind)
.WhichPlayer = WhPlayer
.IndexR = 6
.MoveType = 1
.CurX = SeatX - LoadMyBul(6).Width \ 2 - (LeftOrRight - 1) * 4
.CurY = SeatY - LoadMyBul(6).Height \ 2
.CurSpeedX = 0
.CurSpeedY = -18
.CurAngle = 0
End With
Call CreateMyBullet(WhPlayer, SeatX, SeatY, 2, 1, LeftOrRight)
Case 3
With PlayMyBul(Ind)
.WhichPlayer = WhPlayer
.IndexR = 7
.MoveType = 1
.CurX = SeatX - LoadMyBul(7).Width \ 2 + (LeftOrRight - 1) * 4
.CurY = SeatY - LoadMyBul(7).Height \ 2
.CurSpeedX = 0
.CurSpeedY = -20
.CurAngle = 0
End With
Call CreateMyBullet(WhPlayer, SeatX, SeatY, 2, 2, LeftOrRight)
Case 4
Ang = (Ang + 1) Mod 360
If Ang Mod 10 = 0 Or Ang Mod 15 = 0 Then
With PlayMyBul(Ind)
.WhichPlayer = WhPlayer
.IndexR = 8
.MoveType = 4
.CurX = SeatX - LoadMyBul(8).Width \ 2 + (LeftOrRight - 1) * 4
.CurY = SeatY - LoadMyBul(8).Height \ 2
'.CurSpeedX = 0
.CurSpeedX = 0 '10 * Cos(Ang)
.CurSpeedY = -8
.CurAngle = Ang
End With
End If
Call CreateMyBullet(WhPlayer, SeatX, SeatY, 2, 3, LeftOrRight)
End Select
Exit For
Case 3
Select Case PowerStage
Case 0, 1
With PlayMyBul(Ind)
.WhichPlayer = WhPlayer
.IndexR = 9
.MoveType = 1
.CurX = SeatX - LoadMyBul(9).Width \ 2
.CurY = SeatY - LoadMyBul(9).Height \ 2
.CurSpeedX = 0
.CurSpeedY = -15
.CurAngle = 0
End With
Case 2
With PlayMyBul(Ind)
.WhichPlayer = WhPlayer
.IndexR = 10
.MoveType = 1
.CurX = SeatX - LoadMyBul(10).Width \ 2 - (LeftOrRight - 1) * 3
.CurY = SeatY - LoadMyBul(10).Height \ 2
.CurSpeedX = 0
.CurSpeedY = -15
.CurAngle = 0
End With
Call CreateMyBullet(WhPlayer, SeatX, SeatY, 3, 1, LeftOrRight)
Case 3
With PlayMyBul(Ind)
.WhichPlayer = WhPlayer
.IndexR = 11
.MoveType = 1
.CurX = SeatX - LoadMyBul(11).Width \ 2 - (LeftOrRight - 1) * 6
.CurY = SeatY - LoadMyBul(11).Height \ 2
.CurSpeedX = 0
.CurSpeedY = -15
.CurAngle = 0
End With
Call CreateMyBullet(WhPlayer, SeatX, SeatY, 3, 2, LeftOrRight)
Case 4
DL = (DL + 1) Mod 10
If DL = 2 Or DL = 3 Then
With PlayMyBul(Ind)
.WhichPlayer = WhPlayer
.IndexR = 12
.MoveType = 3
.CurX = SeatX - LoadMyBul(12).Width \ 2
.CurY = SeatY - LoadMyBul(12).Height \ 2
.CurSpeedX = (LeftOrRight - 1) * 10
.CurSpeedY = -8
.CurAngle = 0
End With
End If
Call CreateMyBullet(WhPlayer, SeatX, SeatY, 3, 3, LeftOrRight)
End Select
Exit For
Case 4 '集彈 1
If SoundMybul = 0 Then SoundMybul = 1: GameSound.PlaySound CStr(LoadMyBul(13).Sound), 1
CountF = CountF + 1
With PlayMyBul(Ind)
.WhichPlayer = WhPlayer
.IndexR = 13
.MoveType = 5
.CurX = PlayPla(WhPlayer).CurX + LoadPla(WhPlayer).Width \ 2 ' SeatX - LoadMyBul(13).Width \ 2
.CurY = PlayPla(WhPlayer).CurY + LoadPla(WhPlayer).Height \ 2
.CurSpeedX = (CountF - 11) / 2 ' * 2
.CurSpeedY = 15
.CurAngle = 0
End With
If CountF = 22 Then Exit For
Case Else: Exit Sub
End Select
End If
Next Ind
CurMyBul = Ind
End Sub
' 因為drawmybullet與其他不同,所以分開寫
Public Sub DrawMyBullet()
Dim DMB As Byte
Dim BltSeatX As Single
Dim BltStartX As Single
For DMB = 1 To MaxMyBul
If PlayMyBul(DMB).IndexR > 0 Then
BltStartX = 0
Select Case PlayMyBul(DMB).MoveType
Case 1
If PlayMyBul(DMB).CurSpeedX >= 0 Then If LoadMyBul(PlayMyBul(DMB).IndexR).IsLeftToRight Then BltStartX = LoadMyBul(PlayMyBul(DMB).IndexR).Width
'Call BltToBuf(LoadMyBul(PlayMyBul(DMB).IndexR).HdcE, LoadMyBul(PlayMyBul(DMB).IndexR).HdcBack, PlayMyBul(DMB).CurX, PlayMyBul(DMB).CurY, CSng(LoadMyBul(PlayMyBul(DMB).IndexR).Width), CSng(LoadMyBul(PlayMyBul(DMB).IndexR).Height), BltStartX)
Case 2 ', 3, 4
Case 3
With PlayMyBul(DMB)
If .CurX < LR + MaxLeft + 10 Then
.CurSpeedX = 10
ElseIf .CurX > LR + MaxRight - 10 Then
.CurSpeedX = -10
End If
End With
Case 4 '4 是正玄曲線
PlayMyBul(DMB).CurAngle = (PlayMyBul(DMB).CurAngle + 1) Mod 360
PlayMyBul(DMB).CurSpeedX = 5 * Cos(PlayMyBul(DMB).CurAngle)
Case 5
With PlayMyBul(DMB)
.CurAngle = .CurAngle + 10
If .CurAngle < 180 Then .CurSpeedY = .CurSpeedY * Cos(CF(.CurAngle))
.CurSpeedY = .CurSpeedY - 1
End With
End Select
Call BltToBuf(LoadMyBul(PlayMyBul(DMB).IndexR).HdcE, LoadMyBul(PlayMyBul(DMB).IndexR).HdcBack, PlayMyBul(DMB).CurX, PlayMyBul(DMB).CurY, CSng(LoadMyBul(PlayMyBul(DMB).IndexR).Width), CSng(LoadMyBul(PlayMyBul(DMB).IndexR).Height), BltStartX)
PlayMyBul(DMB).CurX = PlayMyBul(DMB).CurX + PlayMyBul(DMB).CurSpeedX
PlayMyBul(DMB).CurY = PlayMyBul(DMB).CurY + PlayMyBul(DMB).CurSpeedY
'Call CrashObjMybul,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
'這一項已經在DrawObject 中實現
If Abs(PlayMyBul(DMB).CurX - MidX) > MidX Or PlayMyBul(DMB).CurY < -10 Then PlayMyBul(DMB).IndexR = 0
End If
Next DMB
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -