CODE
Public Class Form1
Const intformsize As Integer = 407
Const intxformsize As Integer = 333
Const intwidthPaddle As Integer = 20
Const intheightPaddle As Integer = 90
Const intwidthball As Integer = 15
Const intwidthPaddle2 As Integer = 20
Const intheightPaddle2 As Integer = 90
Const intheightball As Integer = 15
Dim intxBall As Integer
Dim intyBall As Integer
Dim intxPaddle As Integer = 367
Dim intyPaddle As Integer = 106
Dim intxPaddle2 As Integer = 12
Dim intyPaddle2 As Integer = 26
Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
If e.KeyCode = Keys.Down Then
intyPaddle = intyPaddle - 10
End If
If e.KeyCode = Keys.Up Then
intyPaddle = intyPaddle + 10
End If
If e.KeyCode = Keys.A Then
intyPaddle2 = intyPaddle - 10
End If
If e.KeyCode = Keys.S Then
intyPaddle2 = intyPaddle2 + 10
End If
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Randomize()
intxPaddle = picPaddle1.Width
intxBall = intxformsize - 200
intyball = Rnd() * intyformsize
tmrLeft.Start()
End Sub
Private Sub tmrRight_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrRight.Tick
intxBall = intxBall + 1
picBlueBall.Location = New System.Drawing.Point(intxBall, intyBall)
If intxBall > intxformsize Then
intxBall = 0
intyBall = Rnd() * (intyformsize - intheightball)
Else
If (intxBall >= intxPaddle2 - intwidthpaddle2) Then
If (intyBall + intwidthball > intyPaddle2) And (intyBall + intwidthball < intyPaddle2 + intheightPaddle2) Then
tmrRight.Stop()
tmrLeft.Start()
End If
End If
End If
End Sub
Private Sub tmrLeft_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrLeft.Tick
intxBall = intxBall - 1
picBlueBall.Location = New System.Drawing.Point(intxBall, intyBall)
If intxBall > intxformsize Then
intxBall = 0
intyBall = Rnd() * (intyformsize - intheightball)
Else
If (intxBall <= intxPaddle + intwidthPaddle) Then
If (intyBall + intwidthball > intyPaddle) And (intyBall + intwidthball < intyPaddle + intheightPaddle) Then
tmrLeft.Stop()
tmrRight.Start()
End If
End If
End If
End Sub
End Class