Find Code:
All Words
Any of the Words
Exact Phrase
Home
:
Code
:
Forums
:
Submit
:
Mailing List
:
About
:
Contact
Code
All
VB.NET
ASP.NET
C#
VB Classic
ASP Classic
Snippets
Popular
Resources
Submit Code
Forums
Articles
Tips
Links
Books
Contest
Link to us
This code took me some thinking, but i figured out...
Author:
USA Geek
E-mail:
Click to e-mail author
Website:
http://www.projectnexus.org
Submitted:
11/19/2000
Version:
VB6
Compatibility:
VB6
Category:
Forms
Views:
9620
This code took me some thinking, but i figured out how to make a "bouncing ball" type effect. It has gravity values, height, and length of bounce.
Declarations:
Dim intX, intY, intHeight, intCountMinus, intLength, intCount As Integer
Code:
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 (i still don't know how to measure it) 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
Home
|
Forums
|
Submit
|
Books
|
Mailing List
|
Advertising
|
About
|
Contact
© 2024 A1VBCode. All rights reserved.
Legal disclaimer & terms of use
Privacy statement