Results 1 to 35 of 35

Thread: physics is fun

  1. #1

    Thread Starter
    So Unbanned DiGiTaIErRoR's Avatar
    Join Date
    Apr 1999
    Location
    /dev/null
    Posts
    4,111

    physics is fun

    Making fun little programs that calculate stuff.

    This is basic balls.
    Attached Files Attached Files

  2. #2

    Thread Starter
    So Unbanned DiGiTaIErRoR's Avatar
    Join Date
    Apr 1999
    Location
    /dev/null
    Posts
    4,111
    Bouncey balls.
    Attached Files Attached Files

  3. #3

    Thread Starter
    So Unbanned DiGiTaIErRoR's Avatar
    Join Date
    Apr 1999
    Location
    /dev/null
    Posts
    4,111
    Bubbles.
    Attached Files Attached Files

  4. #4
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373
    perhaps you should post the source instead of the compiled exe

  5. #5

    Thread Starter
    So Unbanned DiGiTaIErRoR's Avatar
    Join Date
    Apr 1999
    Location
    /dev/null
    Posts
    4,111
    Not sure what I want to do with it yet.

    Maybe I'll post the source later.

  6. #6
    Addicted Member
    Join Date
    Jul 2002
    Location
    Ontario Canada
    Posts
    236
    What was your method for making the balls bounce of each other? I want to know how to do that.

    PS I'm not going to be using Visual Basic so if you could just explain like a general algorithm, i would be thankful.
    YL says:"Few are those who see with their own eyes and feel with their own hearts."(Einstein)

  7. #7

    Thread Starter
    So Unbanned DiGiTaIErRoR's Avatar
    Join Date
    Apr 1999
    Location
    /dev/null
    Posts
    4,111
    The code is optimized for the structures.

    Unless you were also using circles my code would probably be of little help to you.

    I use the distance formula to find the distance between centers, then check to see if that's less than the radii of the circles combined. If so 'lengthly algo here'. Also, using a a^2+b^2=c^2 deviation, I calculate the points where the centers of the two collosioning objects should be. The hope is of course they don't overlap and using this method has given me decent results.

    The bouncing is determained by the x,y (again a^2+b^2=c^2, find C from the movements). That is used to conserve momentum.



    There are also friction and gravity forces.

    The method I use for determaining the resultant vector post collide isn't very accurate, but for all intents of this program, it suffices. The objects trade vectors. There is no glancing programming yet. I am, however; making advances towards such.

  8. #8

    Thread Starter
    So Unbanned DiGiTaIErRoR's Avatar
    Join Date
    Apr 1999
    Location
    /dev/null
    Posts
    4,111
    Here's a more functional version.

    Left clicking on a ball with read it's info until deselected.

    Right clicking on a ball will make it a magnet until deselected.

    You Can tweak Gravity(higher is more) and...

    Friction Free(1 = None, 0 = Pure Friction, > 1 = speeding up).
    Attached Files Attached Files

  9. #9
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863
    Why do the balls/bubbles sometimes do overlap?
    Is it that you only check for a fixed number of collisions at a time?
    You're welcome to rate this post!
    If your problem is solved, please use the Mark thread as resolved button


    Wait, I'm too old to hurry!

  10. #10

    Thread Starter
    So Unbanned DiGiTaIErRoR's Avatar
    Join Date
    Apr 1999
    Location
    /dev/null
    Posts
    4,111
    Originally posted by opus
    Why do the balls/bubbles sometimes do overlap?
    Is it that you only check for a fixed number of collisions at a time?
    The ballPhysics.zip contains an update routine for checking such things.

    For each ball the same process is used.

    Each point is looped, then for each point every other point is checked for collision.

  11. #11

    Thread Starter
    So Unbanned DiGiTaIErRoR's Avatar
    Join Date
    Apr 1999
    Location
    /dev/null
    Posts
    4,111
    For an example, if you resize the window until very tiny, then maximize, you'll see the balls literally popping out.

  12. #12
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863
    maybe I don't get your point, but I see bubbles that overlap each other (not only the shaded part, but also the solid blue part up to the white light-reflection).
    ust look at a bubble in the middle of a big number of others.
    I think at some times another bubble can overrun the investigated.
    You're welcome to rate this post!
    If your problem is solved, please use the Mark thread as resolved button


    Wait, I'm too old to hurry!

  13. #13

    Thread Starter
    So Unbanned DiGiTaIErRoR's Avatar
    Join Date
    Apr 1999
    Location
    /dev/null
    Posts
    4,111
    The engine is only as accurate was what's calculated. This isn't nature and things just happen!

    Yeah, things can overlap, if found the code will reposition them.

    This depends on the version of course.<- !! All prior to the latest release don't have the enchancement.

    ...I'm thinking about making one in 3d.

    And I didn't use any references for this. Just what I know. So that granted, I did pretty well.(i think)

  14. #14
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863
    That's a YES
    Or in Navy-language BZ
    You're welcome to rate this post!
    If your problem is solved, please use the Mark thread as resolved button


    Wait, I'm too old to hurry!

  15. #15
    Hyperactive Member
    Join Date
    Feb 2000
    Location
    Sedgefield
    Posts
    337

    Perfect Systems

    Your balls and bouncing balls are perfect systems - they don't loose energy.

    Maybe you could add an ambient property 'Temperature', so your balls can loose energy as heat.

    Just a thought.

    Dan

    Outside of a dog, a book is a man's best friend.
    Inside of a dog, it's too dark to read.

  16. #16

    Thread Starter
    So Unbanned DiGiTaIErRoR's Avatar
    Join Date
    Apr 1999
    Location
    /dev/null
    Posts
    4,111

    Re: Perfect Systems

    Originally posted by Judd
    Your balls and bouncing balls are perfect systems - they don't loose energy.

    Maybe you could add an ambient property 'Temperature', so your balls can loose energy as heat.

    Just a thought.
    It's more about physical appearance, and it's speed of calculation.

    I just added the point info for technical fun.

    BTW: those are earlier versions. Physics versions have such forces as friction and gravity.
    Last edited by DiGiTaIErRoR; Dec 4th, 2002 at 12:10 PM.

  17. #17
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    Do one on inelastic oblique collisions.

  18. #18

    Thread Starter
    So Unbanned DiGiTaIErRoR's Avatar
    Join Date
    Apr 1999
    Location
    /dev/null
    Posts
    4,111
    I've developed two different collision routines.

    The first is far better at conservation of momentum, while the second yields more precise resultant vectors. But the magnitude of such results are not at all accurate as the first's.

    This first code:

    VB Code:
    1. If Points(Y).Size < 1 Then Points(Y).Size = 1
    2.                 pd = (Points(X).Size / Points(Y).Size) / 2
    3.            
    4.                 P1mx = (Points(X).Move.X)
    5.                 P1my = (Points(X).Move.Y)
    6.                 If Points(X).Size < 1 Then Points(X).Size = 1
    7.                 If Points(X).Size > Points(Y).Size Then
    8.                     pd = (Points(X).Size / Points(Y).Size)
    9.                     Points(X).Move.X = (Points(Y).Move.X / pd) * Fric
    10.                     Points(X).Move.Y = (Points(Y).Move.Y / pd) * Fric
    11.                     Points(Y).Move.X = (P1mx * pd) * Fric
    12.                     Points(Y).Move.Y = (P1my * pd) * Fric '
    13.  
    14.                 Else
    15.                     pd = (Points(Y).Size / (Points(X).Size))
    16.                     Points(X).Move.X = (Points(Y).Move.X * pd) * Fric
    17.                     Points(X).Move.Y = (Points(Y).Move.Y * pd) * Fric
    18.                     Points(Y).Move.X = (P1mx / pd) * Fric
    19.                     Points(Y).Move.Y = (P1my / pd) * Fric
    20.                 End If

    The second.
    VB Code:
    1. pxmx = Points(X).Move.X
    2.                     pxmy = Points(X).Move.Y
    3.                     pymx = Points(Y).Move.X
    4.                     pymy = Points(Y).Move.Y
    5.                    
    6.                     If Points(X).Size > Points(Y).Size Then
    7.                         Points(X).Move.X = (((xRadii + yRadii) * xd) / dist * Fric)
    8.                         Points(X).Move.Y = (((xRadii + yRadii) * yd) / dist * Fric)
    9.                         Points(Y).Move.X = -(((xRadii + yRadii) * xd) / dist * Fric)
    10.                         Points(Y).Move.Y = -(((xRadii + yRadii) * yd) / dist * Fric)
    11.                     Else
    12.                         Points(X).Move.X = (((xRadii + yRadii) * xd) / dist * Fric)
    13.                         Points(X).Move.Y = (((xRadii + yRadii) * yd) / dist * Fric)
    14.                         Points(Y).Move.X = -(((xRadii + yRadii) * xd) / dist * Fric)
    15.                         Points(Y).Move.X = -(((xRadii + yRadii) * yd) / dist * Fric)
    16.                     End If

    Points is defined as:
    VB Code:
    1. Private Points() As pPoint
    2.  
    3. 'pPoint is:
    4.  
    5. Private Type pPoint
    6. Loc As sPoint
    7. Move As sPoint
    8. Size As Long
    9. Color As rgbCol
    10. LastColl As Long
    11. End Type
    12.  
    13. 'which uses:
    14.  
    15. Private Type sPoint
    16. X As Single
    17. Y As Single
    18. End Type
    19.  
    20. Private Type rgbCol
    21. r As Long
    22. g As Long
    23. b As Long
    24. End Type

    When colliding:
    VB Code:
    1. If dist > 1 Then
    2.                     Points(X).Loc.X = Points(Y).Loc.X + ((xRadii + yRadii) * xd) / dist
    3.                     Points(X).Loc.Y = Points(Y).Loc.Y + ((xRadii + yRadii) * yd) / dist
    4.                     Points(Y).Loc.X = Points(X).Loc.X - ((xRadii + yRadii) * xd) / dist
    5.                     Points(Y).Loc.Y = Points(X).Loc.Y - ((xRadii + yRadii) * yd) / dist
    6. End If

    Sets each particle's location out of the other particle.

  19. #19

    Thread Starter
    So Unbanned DiGiTaIErRoR's Avatar
    Join Date
    Apr 1999
    Location
    /dev/null
    Posts
    4,111
    Originally posted by plenderj
    Do one on inelastic oblique collisions.
    I've actually made minor modifications that will yield inelastic collisions.

    If you change the second code, to set the other particle's position as it's own, this requires you buffer the original spots. (as is done)

    Poly particles will form, like molecules, and they 'can' break away though.

    I have a lot of commented codes in my project.

  20. #20

    Thread Starter
    So Unbanned DiGiTaIErRoR's Avatar
    Join Date
    Apr 1999
    Location
    /dev/null
    Posts
    4,111
    Ok, here's the source code.
    Attached Files Attached Files

  21. #21
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Two balls colliding at high speed, overlaps each other if the collision detection is performed after the balls have moved. This also results in incorrect distribution of momentum. I had to solve this problem once earlier:
    http://www.vbforums.com/showthread.p...threadid=75004
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  22. #22

    Thread Starter
    So Unbanned DiGiTaIErRoR's Avatar
    Join Date
    Apr 1999
    Location
    /dev/null
    Posts
    4,111
    Originally posted by kedaman
    Two balls colliding at high speed, overlaps each other if the collision detection is performed after the balls have moved. This also results in incorrect distribution of momentum. I had to solve this problem once earlier:
    http://www.vbforums.com/showthread.p...threadid=75004
    I modify the code to check such things.

    The problem is there really is no time varible.

    I could however move both particles to their destinations then if the dist > radii then step back. The problem is the stepping back just adds further calculation.

    Precision over accuracy.

  23. #23
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    You calculate the time at which the collision occurs relative to the time unit at which you move the balls one step in your loop, from the formula of distance per velocity t=x/v, in this case |X+Vt|=r1+r2, X and V are the position and velocity vectors of which one of the balls moves relative to the other.
    Last edited by kedaman; Dec 4th, 2002 at 08:56 PM.
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  24. #24

    Thread Starter
    So Unbanned DiGiTaIErRoR's Avatar
    Join Date
    Apr 1999
    Location
    /dev/null
    Posts
    4,111
    Originally posted by kedaman
    You calculate the time at which the collision occurs relative to the time unit at which you move the balls one step in your loop, from the formula of distance per velocity t=x/v, in this case |X+Vt|=r1+r2, X and V are the position and velocity vectors of which one of the balls moves relative to the other.
    There's the source code *looks up a few posts*.

    Feel free to add your additions then post an updated version.

  25. #25
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    can't be arsed with vb hehe
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  26. #26

    Thread Starter
    So Unbanned DiGiTaIErRoR's Avatar
    Join Date
    Apr 1999
    Location
    /dev/null
    Posts
    4,111
    Arkanoid clone.

    Going to add ball collisions eventually. As well as power-ups, etc.
    Attached Files Attached Files

  27. #27

    Thread Starter
    So Unbanned DiGiTaIErRoR's Avatar
    Join Date
    Apr 1999
    Location
    /dev/null
    Posts
    4,111
    Fackaball version .6

    What's new?

    -added 10 power ups. (from .2)
    -minor bug fixes
    Attached Files Attached Files

  28. #28
    Hyperactive Member VBD's Avatar
    Join Date
    Apr 2001
    Location
    The Place Above The Place Below Heavin
    Posts
    278
    Very sweet!
    You should submit it to PSC(Planet-source-code.com). You'd get some sweet ratings
    Hello

  29. #29

    Thread Starter
    So Unbanned DiGiTaIErRoR's Avatar
    Join Date
    Apr 1999
    Location
    /dev/null
    Posts
    4,111
    Originally posted by VBD
    Very sweet!
    You should submit it to PSC(Planet-source-code.com). You'd get some sweet ratings
    It needs some major optimizations.

    On lower-end systems the game is incredibly slow.

    A good 10 minutes per level... if not more.

    I plan to replace the shapes with GDI API. Or perhaps... bitblt... bitblt would be sexy....

    Thanks for the 'sweet' comment though.


  30. #30
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863
    Hi,
    nice game, but


    I'm using it on a Win2000 system, and whren clicking on FullScreen a second window for fullscreeen is created, but the original one remains there. The second (full screen) one has just the window title and a black background.
    Is that correct?
    You're welcome to rate this post!
    If your problem is solved, please use the Mark thread as resolved button


    Wait, I'm too old to hurry!

  31. #31
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    'tis a lovely app.
    Noticed a couple of things myself though.

    The physics isn't quite right.
    Even if the ball hits the corner of the block, it continues on upwards.

    The speed of the balls seems to jump dramatically sometimes.

    The paddle at the bottoms blinks quite a lot.

    And if you go into Demo, you have some partial control over the paddle, and can also fire the guns...
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  32. #32
    Hyperactive Member VBD's Avatar
    Join Date
    Apr 2001
    Location
    The Place Above The Place Below Heavin
    Posts
    278

    If you want to save some time...

    To use the bitblt api, without all the code, load into the image list control. Then,
    ImageList1.ListImages(0).Draw Me.Hdc, X, Y
    It is about just as fast but with much less code.

    Just a tip.

    I didn't notice the slowness. I gues thats cause of my comp. It runs smooth....
    Hello

  33. #33

    Thread Starter
    So Unbanned DiGiTaIErRoR's Avatar
    Join Date
    Apr 1999
    Location
    /dev/null
    Posts
    4,111
    A login converter...
    Attached Files Attached Files
    Last edited by DiGiTaIErRoR; Mar 29th, 2003 at 01:18 AM.

  34. #34
    Hyperactive Member VBD's Avatar
    Join Date
    Apr 2001
    Location
    The Place Above The Place Below Heavin
    Posts
    278

    Question ??

    WHat login is it for? Whats it do?
    Hello

  35. #35

    Thread Starter
    So Unbanned DiGiTaIErRoR's Avatar
    Join Date
    Apr 1999
    Location
    /dev/null
    Posts
    4,111

    Re: ??

    Originally posted by VBD
    WHat login is it for? Whats it do?
    Converts say...

    http://user[email protected]

    to

    http://site.com L:user Pass

    for site lists.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width