Public Class Form1
Dim size As Single = 10
Dim draw As Boolean = False
Dim drawprev As Boolean = False
Dim ballnum As Integer = 0
Dim aryX(0) As Integer
Dim aryY(0) As Integer
Dim arySize(0) As Integer
Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
If e.KeyCode = Keys.Enter Then
Me.Close()
End If
If e.KeyCode = Keys.Space Then
MsgBox(ballnum)
End If
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
size = size + 2
If Cursor.Position.X + size / 2 > Screen.PrimaryScreen.Bounds.Width Then
System.Windows.Forms.Cursor.Position = New Point(Screen.PrimaryScreen.Bounds.Width - size / 2, Cursor.Position.Y)
End If
If Cursor.Position.X - size / 2 < 0 Then
System.Windows.Forms.Cursor.Position = New Point(size / 2, Cursor.Position.Y)
End If
If Cursor.Position.Y + size / 2 > Screen.PrimaryScreen.Bounds.Height Then
System.Windows.Forms.Cursor.Position = New Point(Cursor.Position.X, Screen.PrimaryScreen.Bounds.Height - size / 2)
End If
If Cursor.Position.Y - size / 2 < 0 Then
System.Windows.Forms.Cursor.Position = New Point(Cursor.Position.X, size / 2)
End If
If size = Screen.PrimaryScreen.Bounds.Height Or size = Screen.PrimaryScreen.Bounds.Width Then
Timer1.Enabled = False
End If
Me.Refresh()
End Sub
Private Sub Form1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDown
draw = True
Timer1.Enabled = True
size = 10
End Sub
Private Sub Form1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseUp
Timer1.Enabled = False
Try
ballnum = ballnum + 1
drawprev = True
ReDim aryX(ballnum)
ReDim aryY(ballnum)
ReDim arySize(ballnum)
aryX(ballnum) = Cursor.Position.X - size / 2
aryY(ballnum) = Cursor.Position.Y - size / 2
arySize(ballnum) = size
Catch
MsgBox("Too many circles made")
End Try
End Sub
Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
If draw = True Then
e.Graphics.FillEllipse(Brushes.Green, Cursor.Position.X - size / 2, Cursor.Position.Y - size / 2, size, size)
If drawprev = True Then
Dim i As Integer = 0
For i = 0 To aryX.GetUpperBound(0)
e.Graphics.FillEllipse(Brushes.Green, aryX(ballnum), aryY(ballnum), arySize(ballnum), arySize(ballnum))
Next
End If
End If
End Sub
End Class