⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 moveplane.txt

📁 一款飞机射击游戏的源代码
💻 TXT
字号:
Private Const VK_DOWN = &H28
Private Const VK_UP = &H26
Private Const VK_LEFT = &H25
Private Const VK_RIGHT = &H27

Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal X As Long, ByVal Y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
Private Declare Function timeGetTime Lib "winmm.dll" () As Long

Dim CurFps As Single
Dim CurX As Single
Dim CurY As Single
Dim isrun As Boolean
Private Sub Form_Activate()
Dim Kt As Long
CurFps = 4
isrun = True
Picture2.Move Picture2.Left, Picture2.Top, Picture2.Width, 200
CurX = 200
CurY = 100
Do While isrun
DoEvents
Kt = timeGetTime
    Picture2.Cls
    BitBlt Picture2.hDC, CurX, CurY, 29, Picture1.Height, Picture1.hDC, (Int(CurFps) - 1) * 29, 0, vbSrcCopy
    If GetAsyncKeyState(VK_LEFT) Then
        CurFps = CurFps - 0.5
        CurX = CurX - 4
        If CurFps <= 1.5 Then CurFps = 1.5
    ElseIf GetAsyncKeyState(VK_RIGHT) Then
        CurFps = CurFps + 0.5
        CurX = CurX + 4
        If CurFps >= 7.5 Then CurFps = 7.5
    Else
        If CurFps >= 4.5 Then
            CurFps = CurFps - 0.5
        ElseIf CurFps < 4 Then
            CurFps = CurFps + 0.5
        End If
    End If
    
    If GetAsyncKeyState(VK_UP) Then
        CurY = CurY - 4
    ElseIf GetAsyncKeyState(VK_DOWN) Then
        CurY = CurY + 4
    End If
        
    
DoEvents
While timeGetTime - Kt < 35
DoEvents
Wend
Loop
End Sub

Private Sub Form_Unload(Cancel As Integer)
isrun = False
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -