How to make a bouncing ball type effect
Posted on January 4, 2009
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | 'Forms - How to make a bouncing ball type effect Dim intX As Integer, intY As Integer, intHeight As Integer, intCountMinus As Integer, _ intLength As Integer, intCount As Integer Private Sub Command1_Click() For intCount = 200 To 0 Step -50 '(X to 0 step Y) X = First bounce height, Y = How much the bounce decreases each time intHeight = intCount + 50 'How high the ball will bounce intLength = 2000 'Length of the bounce intY = ScaleHeight 'Sets the vertical starting position of a bounce intCountMinus = (intHeight / 100) 'intCountMinus = (intHeight/X) --> X = gravity, increase for more gravity Do Until intY > ScaleHeight 'Loops until ball hits the "ground" intX = intX + (intLength / 200) 'intX moves towards its length by intervals of 1/200 the length intY = intY - intHeight 'Moves the ball up by intHeight intHeight = intHeight - intCountMinus 'Intheight is subtracted from Circle (intX, intY), 300 'Draws the ball Loop Next intCount End Sub Private Sub Form_Load() intX = 0 'Left/right starting point of ball End Sub |