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

📄 form1.frm

📁 VB6+DX7开发即时战略游戏(游戏代码+编辑器)
💻 FRM
📖 第 1 页 / 共 5 页
字号:
                        If Enemy1_Date(j).GunTowerCurSin >= 0.195 And Enemy1_Date(j).GunTowerCurSin < 0.556 Then
                        .Left = SpriteTileSize * i
                        .Right = SpriteTileSize * (i + 1)
                        End If
                        i = i + 1
                        
                        If Enemy1_Date(j).GunTowerCurSin >= -0.195 And Enemy1_Date(j).GunTowerCurSin < 0.195 Then
                        .Left = SpriteTileSize * i
                        .Right = SpriteTileSize * (i + 1)
                        End If
                        i = i + 1
                        
                        If Enemy1_Date(j).GunTowerCurSin >= -0.556 And Enemy1_Date(j).GunTowerCurSin < -0.195 Then
                        .Left = SpriteTileSize * i
                        .Right = SpriteTileSize * (i + 1)
                        End If
                        i = i + 1
                        
                        If Enemy1_Date(j).GunTowerCurSin >= -0.831 And Enemy1_Date(j).GunTowerCurSin < -0.556 Then
                        .Left = SpriteTileSize * i
                        .Right = SpriteTileSize * (i + 1)
                        End If
                        i = i + 1
                        
                        If Enemy1_Date(j).GunTowerCurSin >= -0.981 And Enemy1_Date(j).GunTowerCurSin < -0.831 Then
                        .Left = SpriteTileSize * i
                        .Right = SpriteTileSize * (i + 1)
                        End If
                        i = 0
                        
                        If Enemy1_Date(j).GunTowerCurSin > -1 And Enemy1_Date(j).GunTowerCurSin < -0.981 Then
                        .Left = SpriteTileSize * i
                        .Right = SpriteTileSize * (i + 1)
                        End If
                                           
                    End If
                    
                    Call BackbufferSurface.Blt(destRect, Ma, srcRect, DDBLT_WAIT Or DDBLT_KEYSRC)
            
                End With
        End If
    End If
Next j

End Sub
Private Sub Form_Load()
InitInputDevice
InitDSound
InitDDraw
InitSurface
InitSystemDate
InitNormalDate

Run
End Sub
Sub DeviceEvent()   '获取外设输入,改变互动数据

'Dim FreeKey As Boolean

Dim i As Integer

Dim x1 As Integer
Dim x2 As Integer
Dim y1 As Integer
Dim y2 As Integer

Dim a As Single
Dim b As Single


    


GetCursorPos MousePos    '获取鼠标坐标
If (MousePos.X <> 400 Or MousePos.Y <> 300) Then
    Ma_Date.GunTowerCurSin = -(MousePos.Y - DisplayHeight / 2) / Sqr((MousePos.Y - DisplayHeight / 2) * (MousePos.Y - DisplayHeight / 2) + (MousePos.X - DisplayWidth / 2) * (MousePos.X - DisplayWidth / 2))
    Ma_Date.GunTowerCurCos = (MousePos.X - DisplayWidth / 2) / Sqr((MousePos.Y - DisplayHeight / 2) * (MousePos.Y - DisplayHeight / 2) + (MousePos.X - DisplayWidth / 2) * (MousePos.X - DisplayWidth / 2))
End If

Call diDEVKeyboard.GetDeviceStateKeyboard(diStateKeyboard)   '获取键盘事件
Call diDEVMouse.GetDeviceStateMouse(diStateMouse)           '获取鼠标事件

If diStateKeyboard.key(1) = 128 Then
    Running = False
    Set D7 = Nothing
    End
End If

If Ma_Date.Hp > 0 Then  '如果我们的座机还生存的话,响应以下键盘事件
        
        If diStateKeyboard.key(30) = 128 And diStateKeyboard.key(32) = 0 And diStateKeyboard.key(17) = 0 And diStateKeyboard.key(31) = 0 Then      'a  左
            Ma_Date.FangXiang = 180     '有问题
            
            With Ma_Date
                a = .Speed
                b = 0
        
                x1 = Int((.CurPosX - a - .R) / BackgroundTile_Width)
                'x2 = Int((.CurPosX + a + .R) / BackgroundTile_Width)
                y1 = Int(-(.CurPosY - b - .R) / BackgroundTile_Height)
                y2 = Int(-(.CurPosY + b + .R) / BackgroundTile_Height)
            End With
            
            If Tile_Date(x1, y1).Pass = True And Tile_Date(x1, y2).Pass = True Then
                Ma_Date.CurPosX = Ma_Date.CurPosX - a
                'Ma_Date.CurPosY = Ma_Date.CurPosY + b
                
            End If
        End If
            
        If diStateKeyboard.key(32) = 128 And diStateKeyboard.key(30) = 0 And diStateKeyboard.key(17) = 0 And diStateKeyboard.key(31) = 0 Then      'd  右
            Ma_Date.FangXiang = 0
             
            With Ma_Date
                a = .Speed
                b = 0
        
                'x1 = Int((.CurPosX - a - .R) / BackgroundTile_Width)
                x2 = Int((.CurPosX + a + .R) / BackgroundTile_Width)
                y1 = Int(-(.CurPosY - b - .R) / BackgroundTile_Height)
                y2 = Int(-(.CurPosY + b + .R) / BackgroundTile_Height)
            End With
             
            If Tile_Date(x2, y1).Pass = True And Tile_Date(x2, y2).Pass = True Then
                Ma_Date.CurPosX = Ma_Date.CurPosX + a
                'Ma_Date.CurPosY = Ma_Date.CurPosY + b
               
            End If
        End If
            
        If diStateKeyboard.key(17) = 128 And diStateKeyboard.key(30) = 0 And diStateKeyboard.key(32) = 0 And diStateKeyboard.key(31) = 0 Then       'w  上
            Ma_Date.FangXiang = 90
            
            With Ma_Date
                a = 0
                b = .Speed
        
                x1 = Int((.CurPosX - a - .R) / BackgroundTile_Width)
                x2 = Int((.CurPosX + a + .R) / BackgroundTile_Width)
                'y1 = Int(-(.CurPosY - b - .R) / BackgroundTile_Height)
                y2 = Int(-(.CurPosY + b + .R) / BackgroundTile_Height)
            End With
            
            If Tile_Date(x1, y2).Pass = True And Tile_Date(x2, y2).Pass = True Then
                'Ma_Date.CurPosX = Ma_Date.CurPosX + a
                Ma_Date.CurPosY = Ma_Date.CurPosY + b
                
            End If
        End If
            
        If diStateKeyboard.key(31) = 128 And diStateKeyboard.key(30) = 0 And diStateKeyboard.key(32) = 0 And diStateKeyboard.key(17) = 0 Then     's  下
            Ma_Date.FangXiang = 270
            
            With Ma_Date    '下
                a = 0
                b = .Speed
        
                x1 = Int((.CurPosX - a - .R) / BackgroundTile_Width)
                x2 = Int((.CurPosX + a + .R) / BackgroundTile_Width)
                y1 = Int(-(.CurPosY - b - .R) / BackgroundTile_Height)
                'y2 = Int(-(.CurPosY + b + .R) / BackgroundTile_Height)
            End With
            
            If Tile_Date(x1, y1).Pass = True And Tile_Date(x2, y1).Pass = True Then
                'Ma_Date.CurPosX = Ma_Date.CurPosX + a
                Ma_Date.CurPosY = Ma_Date.CurPosY - b
                
            End If
        End If
        
        If diStateKeyboard.key(32) = 128 And diStateKeyboard.key(17) = 128 And diStateKeyboard.key(30) = 0 And diStateKeyboard.key(31) = 0 Then     '右上
            Ma_Date.FangXiang = 45
            
            With Ma_Date    '右
                a = .Speed * Sqr(2) / 2
                b = 0
        
                'x1 = Int((.CurPosX - a - .R) / BackgroundTile_Width)
                x2 = Int((.CurPosX + a + .R) / BackgroundTile_Width)
                y1 = Int(-(.CurPosY - b - .R) / BackgroundTile_Height)
                y2 = Int(-(.CurPosY + b + .R) / BackgroundTile_Height)
            End With
             
            If Tile_Date(x2, y1).Pass = True And Tile_Date(x2, y2).Pass = True Then
                Ma_Date.CurPosX = Ma_Date.CurPosX + a
                'Ma_Date.CurPosY = Ma_Date.CurPosY + b
               
            End If
            
            With Ma_Date    '上
                a = 0
                b = .Speed * Sqr(2) / 2
        
                x1 = Int((.CurPosX - a - .R) / BackgroundTile_Width)
                x2 = Int((.CurPosX + a + .R) / BackgroundTile_Width)
                'y1 = Int(-(.CurPosY - b - .R) / BackgroundTile_Height)
                y2 = Int(-(.CurPosY + b + .R) / BackgroundTile_Height)
            End With
            
            If Tile_Date(x1, y2).Pass = True And Tile_Date(x2, y2).Pass = True Then
                'Ma_Date.CurPosX = Ma_Date.CurPosX + a
                Ma_Date.CurPosY = Ma_Date.CurPosY + b
                
            End If
            
            
        End If
        
        If diStateKeyboard.key(30) = 128 And diStateKeyboard.key(17) = 128 And diStateKeyboard.key(32) = 0 And diStateKeyboard.key(31) = 0 Then       '左上
            Ma_Date.FangXiang = 135
            
            With Ma_Date    '左
                a = .Speed * Sqr(2) / 2
                b = 0
        
                x1 = Int((.CurPosX - a - .R) / BackgroundTile_Width)
                'x2 = Int((.CurPosX + a + .R) / BackgroundTile_Width)
                y1 = Int(-(.CurPosY - b - .R) / BackgroundTile_Height)
                y2 = Int(-(.CurPosY + b + .R) / BackgroundTile_Height)
            End With
            
            If Tile_Date(x1, y1).Pass = True And Tile_Date(x1, y2).Pass = True Then
                Ma_Date.CurPosX = Ma_Date.CurPosX - a
                'Ma_Date.CurPosY = Ma_Date.CurPosY + b
                
            End If
            
            With Ma_Date    '上
                a = 0
                b = .Speed * Sqr(2) / 2
        
                x1 = Int((.CurPosX - a - .R) / BackgroundTile_Width)
                x2 = Int((.CurPosX + a + .R) / BackgroundTile_Width)
                'y1 = Int(-(.CurPosY - b - .R) / BackgroundTile_Height)
                y2 = Int(-(.CurPosY + b + .R) / BackgroundTile_Height)
            End With
            
            If Tile_Date(x1, y2).Pass = True And Tile_Date(x2, y2).Pass = True Then
                'Ma_Date.CurPosX = Ma_Date.CurPosX + a
                Ma_Date.CurPosY = Ma_Date.CurPosY + b
                
            End If
            
        End If
        
        If diStateKeyboard.key(30) = 128 And diStateKeyboard.key(31) = 128 And diStateKeyboard.key(32) = 0 And diStateKeyboard.key(17) = 0 Then      '左下
            Ma_Date.FangXiang = 225
            
            With Ma_Date    '左
                a = .Speed * Sqr(2) / 2
                b = 0
        
                x1 = Int((.CurPosX - a - .R) / BackgroundTile_Width)
                'x2 = Int((.CurPosX + a + .R) / BackgroundTile_Width)
                y1 = Int(-(.CurPosY - b - .R) / BackgroundTile_Height)
                y2 = Int(-(.CurPosY + b + .R) / BackgroundTile_Height)
            End With
            
            If Tile_Date(x1, y1).Pass = True And Tile_Date(x1, y2).Pass = True Then
                Ma_Date.CurPosX = Ma_Date.CurPosX - a
                'Ma_Date.CurPosY = Ma_Date.CurPosY + b
                
            End If
            
            With Ma_Date    '下
                a = 0
                b = .Speed * Sqr(2) / 2
        
                x1 = Int((.CurPosX - a - .R) / BackgroundTile_Width)
                x2 = Int((.CurPosX + a + .R) / BackgroundTile_Width)
                y1 = Int(-(.CurPosY - b - .R) / BackgroundTile_Height)
                'y2 = Int(-(.CurPosY + b + .R) / BackgroundTile_Height)
            End With
            
            If Tile_Date(x1, y1).Pass = True And Tile_Date(x2, y1).Pass = True Then
                'Ma_Date.CurPosX = Ma_Date.CurPosX + a
                Ma_Date.CurPosY = Ma_Date.CurPosY - b
                
            End If
            
        End If
        
        If diStateKeyboard.key(32) = 128 And diStateKeyboard.key(31) = 128 And diStateKeyboard.key(30) = 0 And diStateKeyboard.key(17) = 0 Then      '右下
            Ma_Date.FangXiang = 315
            
            With Ma_Date    '右
                a = .Speed * Sqr(2) / 2
                b = 0
        
                'x1 = Int((.CurPosX - a - .R) / BackgroundTile_Width)
                x2 = Int((.CurPosX + a + .R) / BackgroundTile_Width)
                y1 = Int(-(.CurPosY - b - .R) / BackgroundTile_Height)
                y2 = Int(-(.CurPosY + b + .R) / BackgroundTile_Height)
            End With
             
            If Tile_Date(x2, y1).Pass = True And Tile_Date(x2, y2).Pass = True Then
                Ma_Date.CurPosX = Ma_Date.CurPosX + a
                'Ma_Date.CurPosY = Ma_Date.CurPosY + b
               
            End If
            
            With Ma_Date    '下
                a = 0
                b = .Speed * Sqr(2) / 2
        
                x1 = Int((.CurPosX - a - .R) / BackgroundTile_Width)
                x2 = Int((.CurPosX + a + .R) / BackgroundTile_Width)
                y1 = Int(-(.CurPosY - b - .R) / BackgroundTile_Height)
                'y2 = Int(-(.CurPosY + b + .R) / BackgroundTile_Height)
            End With
            
            If Tile_Date(x1, y1).Pass = True And Tile_Date(x2, y1).Pass = True Then
                'Ma_Date.CurPosX = Ma_Date.CurPosX + a
                Ma_Date.CurPosY = Ma_Date.CurPosY - b
                
            End If
            
        End If
                
        If diStateMouse.buttons(1) = 128 And Ma_Date.Attack_Interval = 0 Then  'mouse_right_click发射子弹
            For i = 0 To 1     '这里有三十颗子弹可以使用,数目可调
                If Ma_ZiDan_Date(i).Shotting = False And Ma_ZiDan_Date(i).Range = 0 Then  '如果子弹处于未发射状态
                    Ma_ZiDan_Date(i).Shotting = True    '则射之
                    Ma_ZiDan_Date(i).Range = ZiDan_Range    '单颗子弹的飞行时间,超出飞行时间则回收
                    'Ma_ZiDan_Date(i).FangXiang = Ma_Date.FangXiang        '子弹的方向和飞机的方向一致
                    Ma_ZiDan_Date(i).CurSin = Ma_Date.GunTowerCurSin
                    Ma_ZiDan_Date(i).CurCos = Ma_Date.GunTowerCurCos
                    Ma_ZiDan_Date(i).CurPosX = Ma_Date.CurPosX '+ Rnd * 11 - 5   '给子弹一个随机的初始位置
                    Ma_ZiDan_Date(i).CurPosY = Ma_Date.CurPosY '+ Rnd * 11 - 5   '制造一个效果,可能还行
                    Ma_Date.Attack_Interval = Ma_Attack_Interval_Time
                    
                    PlayShotWav     '播放射击时的声音
                
                    Exit For    '每frame调用一颗子弹,调用完毕就退出循环
                
                End If
            Next i
        
        End If
        
        
        
        If Tile_Date(Ma_Date.CurPosX / BackgroundTile_Width, -Ma_Date.CurPosY / BackgroundTile_Height).MapIndex <> 0 Then
            Select Case Tile_Date(Ma_Date.CurPosX / BackgroundTile_Width, -Ma_Date.CurPosY / BackgroundTile_Height).MapIndex
                Case 1
                    CurrentMap = 1
                Case 2
                    CurrentMap = 2
                Case 1.1
                    CurrentMap = 1.1
            End Select
            InitNormalDate

⌨️ 快捷键说明

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