Public Class Form1
Dim x, y As Integer
Dim ballx, bally As Boolean
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
x = Pic1.Location.X
y = Pic1.Location.Y
ballx = True
bally = True
Timer1.Start()
End Sub
Private Sub ball1()
If Pic1.Location.X + 3 >= 640 Then
ballx = False
ElseIf Pic1.Location.X + 3 <= 0 Then
ballx = True
End If
If Pic1.Location.Y + 3 >= 350 Then
bally = False
ElseIf Pic1.Location.Y + 3 <= 0 Then
bally = True
End If
If ballx = True Then
x += 7
Else
x -= 7
End If
If bally = True Then
y += 7
Else
y -= 7
End If
Pic1.Location = New System.Drawing.Point(x, y)
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
ball1()
End Sub
End Class
Tidak ada komentar:
Posting Komentar