level 2
qq5646948
楼主

Public Class Form1Private Score As Integer = 0
Private Vx As Double = 5
Private Vy As Double = 5
Private MDx As Integer Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.BackColor = Color.FromArgb(204, 232, 207)
End Sub Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
B.Left += Vx
B.Top += Vy
If B.Left < 0 Then
Vx = Math.Abs(Vx)
End If
If B.Right > Me.ClientSize.Width Then
Vx = -Math.Abs(Vx)
End If
If B.Top < 0 Then
Vy = Math.Abs(Vy)
End If
If B.Bottom > P.Top Then
Dim C As Integer = (B.Left + B.Right) / 2
If C >= P.Left AndAlso C <= P.Right Then
Dim F As Double = (CDbl(C) - CDbl(P.Left)) / CDbl(P.Width)
If Vx < 0 Then
F = (1.0 - F)
End If
F = F + 0.5
Vx = CInt(Math.Round(Vx * F))
Vy = -Math.Abs(Vy)
Score = Score + 10
Me.Text = "分数:" & Score.ToString()
Else
If B.Bottom > Me.ClientSize.Height Then
Timer1.Stop()
MsgBox("Game Over!", , "提示")
B.Left = 220
B.Top = 200
Score = 0
Vx = 5
Vy = 5
Me.Text = "分数:" & Score.ToString()
End If
End If
End If
End Sub Private Sub P_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs) Handles P.MouseDown
Timer1.Start()
Cursor.Current = Cursors.Hand
MDx = e.X
End Sub Private Sub P_MouseMove(ByVal sender As Object, ByVal e As MouseEventArgs) Handles P.MouseMove
If e.Button = MouseButtons.Left Then
Dim x As Integer = P.Left + (e.X - MDx)
If x < 0 Then
x = 0
End If
If x > Me.ClientSize.Width - P.Width Then
x = Me.ClientSize.Width - P.Width
End If
P.Left = x
End If
End Sub End Class
能不能解释下代码里的private Vx,Vy,MDx,分别代表什么意思。 如果可以的能不能插点解释,大概每段代码是什么意思。谢谢拉
