Public Class Form1
'Nº de bolas:
Dim x As Integer = 5
Dim pic(x) As PictureBox
Dim random As New Random
Dim
switch_color As Boolean
Private Sub Form1_Load(ByVal
sender As System.Object,
ByVal e As
System.EventArgs) Handles
MyBase.Load
'Criação de bolas em runtime
For i As Integer = 0 To x
'Gera Posições (X e Y) aleatórias
Dim random_x As Integer = random.Next(0, Me.Width)
Dim
random_y As Integer
= random.Next(0, Me.Height)
pic(i) = New
PictureBox
pic(i).Name = i
If
(switch_color = True) Then
pic(i).Image = My.Resources.internet 'My.Resources.internet
= é a imagem que coloquei na pasta resources da aplicação
switch_color = False
Else
pic(i).Image = My.Resources.News 'My.Resources.internet = é a imagem que coloquei na pasta
resources da aplicação
switch_color = True
End
If
pic(i).BackColor = Color.Transparent
pic(i).SizeMode = PictureBoxSizeMode.Zoom
pic(i).Location = New Point(random_x,
random_y)
Me.Controls.Add(pic(i))
Next
Timer1.Enabled = True
End Sub
Private Sub Timer1_Tick(ByVal
sender As System.Object,
ByVal e As
System.EventArgs) Handles
Timer1.Tick
For i As Integer = 0 To x
pic(i).Location = New Point(pic(i).Location.X,
pic(i).Location.Y + 30)
'Verifica se a bola está fora dos limites da
tela ou não
If (pic(i).Location.Y > Me.Height)
Then
pic(i).Location = New Point(pic(i).Location.X,
0)
End
If
Next
End Sub
End
Class
0 comentários:
Postar um comentário