版权声明: https://blog.csdn.net/eds124/article/details/82316161
Public Class Form1
Private y As Integer = 900, x As Integer = 900, speed As Integer = 10, edsf As Integer = 0, ky As Integer = 1000
Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
Dim k As Keys = e.KeyCode
If Keys.E = k And y > 0 Then
y -= speed
edsf = 0
ElseIf Keys.D = k And y < 900 Then
y += speed
edsf = 1
ElseIf Keys.S = k And x > 0 Then
x -= speed
edsf = 2
ElseIf Keys.F = k And x < 1800 Then
x += speed
edsf = 3
ElseIf Keys.K = k And ky > 800 Then
ky -= 200
ElseIf Keys.J = k And ky < 1000 Then
ky += 200
End If
Me.Refresh()
Dim r As Random = New Random()
If (r.Next(20) = 0) Then
MsgBox("遇见敌人,这里切换画面")
End If
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Me.BackColor = Color.Black
Me.BackgroundImage = New Bitmap("C:\Users\Administrator\AppData\Local\Temporary Projects\WindowsApplication1\img\dq3map.gif")
Me.WindowState = FormWindowState.Maximized
End Sub
Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
Dim g As Graphics = e.Graphics
Dim imgurl As String = ""
If edsf = 0 Then
imgurl = "C:\Users\Administrator\AppData\Local\Temporary Projects\WindowsApplication1\img\tank8u.gif"
ElseIf edsf = 1 Then
imgurl = "C:\Users\Administrator\AppData\Local\Temporary Projects\WindowsApplication1\img\tank8d.gif"
ElseIf edsf = 2 Then
imgurl = "C:\Users\Administrator\AppData\Local\Temporary Projects\WindowsApplication1\img\tank8l.gif"
ElseIf edsf = 3 Then
imgurl = "C:\Users\Administrator\AppData\Local\Temporary Projects\WindowsApplication1\img\tank8r.gif"
End If
Dim b As Bitmap = New Bitmap(imgurl)
g.DrawImage(b, x, y)
g.FillRectangle(Brushes.Pink, 0, ky, 1900, 200)
g.DrawString("对话", New Font("黑体", 50, FontStyle.Bold), Brushes.Blue, 0, ky)
g.DrawString("强度", New Font("黑体", 50, FontStyle.Bold), Brushes.Blue, 200, ky)
g.DrawString("装备", New Font("黑体", 50, FontStyle.Bold), Brushes.Blue, 400, ky)
g.DrawString("调查", New Font("黑体", 50, FontStyle.Bold), Brushes.Blue, 600, ky)
g.DrawString("乘降", New Font("黑体", 50, FontStyle.Bold), Brushes.Blue, 0, ky + 100)
g.DrawString("道具", New Font("黑体", 50, FontStyle.Bold), Brushes.Blue, 200, ky + 100)
g.DrawString("炮弹", New Font("黑体", 50, FontStyle.Bold), Brushes.Blue, 400, ky + 100)
g.DrawString("模式", New Font("黑体", 50, FontStyle.Bold), Brushes.Blue, 600, ky + 100)
End Sub
End Class