Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Java 2d physics
#6
Just to confirm, clearing the screen every frame is the normal way of animation. Its how everything else works, including 3d graphics libraries like OpenGl, etc.

For detecting the collision between two spheres (that part's very easy and I'm sure you've figured it out already). Just take the distance between the spheres and if it is less then the two radii combined, then they are colliding.
For the response after the collision, an easy way to do it is:
Find the direction between the centre of the two particles.
The velocities perpindicular to that direction do not change.
The momentum in that direction of the two particles react with each other as if it were a 1d collision.
That will give a pefectly elastic collision.

If this isn't specific enough, I can go into more detail.
Reply


Messages In This Thread
Java 2d physics - by Stereo - 2009-02-05, 10:23 PM
Java 2d physics - by Spaz - 2009-02-06, 08:31 PM
Java 2d physics - by Stereo - 2009-02-06, 11:04 PM
Java 2d physics - by Spaz - 2009-02-07, 03:13 AM
Java 2d physics - by Stereo - 2009-02-07, 01:57 PM
Java 2d physics - by DeadHead - 2009-02-08, 08:42 PM
Java 2d physics - by Stereo - 2009-02-09, 10:30 AM
Java 2d physics - by DeadHead - 2009-02-10, 03:40 AM
Java 2d physics - by Stereo - 2009-02-10, 10:25 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)