Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleAnimate a bouncing ball on a blank background
Keywordsbouncing ball, animation, blank background
CategoriesMultimedia, Graphics
 
Use Line to erase the ball. Then draw the ball in its new location. When the ball gets too close to the edge of the picture, reverse the sign of its X or Y velocity.
 
' Draw the ball at (CurX, CurY).
Private Sub DrawBall()
    ' Fix the part of the image that was covered.
    picCanvas.Line _
        (OldX - BallR, OldY - BallR)- _
        Step(BallD, BallD), picCanvas.BackColor, BF
    OldX = CurX
    OldY = CurY

    ' Redraw the ball.
    picCanvas.Circle (CurX, CurY), BallR

    ' Update the display.
    picCanvas.Refresh
End Sub
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated