This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Ball Physics implementation. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Ball Physics implementation. " Watch "Ball Physics implementation. " New topic
Author

Ball Physics implementation.

Jibby Lala
Ranch Hand

Joined: Aug 29, 2010
Posts: 35
Dear experts,

I wanted to implement ball physics and as i m newbie, i adapt the code in tutorial
http://adam21.web.officelive.com/Documents/JavaPhysicsTutorial.pdf.

i try to follow that as i much as i can,
but i m not able to apply all physical phenomenon in code, can somebody please tell me, where i m mistaken or i m still doing some silly programming mistake , the balls are moving when i m not calling bounce method and i m unable to avail the bounce method and ball are moving towards left side instead of falling/ending on floor,


Can some body can recommend me some better way or similar way to accomplish this task of applying physics on two ball or more balls ,

here is code ;



using Adobeball




load of thanks
jibby
pete stein
Bartender

Joined: Feb 23, 2007
Posts: 1561
That's a lot of code to go through -- so I'm not.

But when my program logic doesn't work as I desire it to, I put on my debugging hat and start debugging like crazy. If you haven't already done so, either use a decent debugger or pepper your code with printlns so that you can see why the program is not behaving as it should.

Best of luck.
Jibby Lala
Ranch Hand

Joined: Aug 29, 2010
Posts: 35
i ordered a DEBUG HAT BUT i thought it will take time to reach as i m newbie
ok, then can you please shift this thread to "game development" section or most likely place to get answer.
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
> ...or most likely place to get answer.

as we can't compile it, or run it, the most likely place is where people enjoy reading --> the library
Jibby Lala
Ranch Hand

Joined: Aug 29, 2010
Posts: 35
why you can't compile or run it?
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
private MyKeyListener pit;
Mike Pukuotukas
Greenhorn

Joined: Oct 08, 2010
Posts: 6
Here is a well working code of the two dimensional ball collision, maybe it can help you.
Jibby Lala
Ranch Hand

Joined: Aug 29, 2010
Posts: 35
Please add this :

Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
> Please add this :

all you are doing is wasting our time:

you have this
private MyKeyListener pit;
pit = new MyKeyListener();

now you've (finally, what 10 days?) posted the MyKeyListener class.

so how do you expect to compile/run with these lines
frame.addMouseListener(pit);
frame.addMouseMotionListener(pit);

perhaps you'll put in a better effort at your (at least) 2 cross-posts
 
jQuery in Action, 2nd edition
 
subject: Ball Physics implementation.
 
Similar Threads
drawing arrows
How to save GUI in XML file and vice versa??
JPanel repainting weirdly
Problem with GUI
New College Project