Posted by: Sourav | December 16, 2013

Bouncing ball animation in Visual Basic 2012


 

Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick

If moveright = True Then

OvalShape1.Left = OvalShape1.Left + 5

Else

OvalShape1.Left = OvalShape1.Left – 5

End If

If OvalShape1.Left <= Me.ClientRectangle.Left Then

Beep()

 

moveright = True

 

 

End If

If OvalShape1.Left + OvalShape1.Width >= Me.DisplayRectangle.Right Then

Beep()

 

moveright = False

 

End If

If moveup = True Then

OvalShape1.Top = OvalShape1.Top + 5

 

End If

If moveup = False Then

OvalShape1.Top = OvalShape1.Top – 5

 

End If

If OvalShape1.Top <= Me.ClientRectangle.Top Then

moveup = False

Beep()

 

 

End If

If OvalShape1.Top + OvalShape1.Height >= Me.ClientRectangle.Bottom Then

moveup = True

Beep()

End If

 

End Sub

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: