반응형
timer Enable 은 반드시 true
Public Class Form1
Dim hs As Integer = -5
Dim vs As Integer = -5
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
If ball.Right > Me.ClientRectangle.Width Then
hs = -hs
End If
If ball.Bottom > Me.ClientRectangle.Height Then
vs = -vs
End If
If ball.Left < 0 Then
hs = -hs
End If
If ball.Top < 0 Then
vs = -vs
End If
ball.Left += hs
ball.Top += vs
End Sub
End Class
반응형