GPWiki.org
GPWiki.org
It is currently Wed May 22, 2013 12:07 pm

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Mon May 09, 2011 1:28 pm 
Rookie

Joined: Tue Apr 26, 2011 1:10 pm
Posts: 1
Hi guys,
I want to develop a billiards game in java,I want to know how can detect collision(ball 2 ball) & take certain actions on that?
Thank you


Top
 Profile  
 
PostPosted: Mon May 09, 2011 3:23 pm 
Bibliotherapist
User avatar

Joined: Wed Nov 03, 2004 1:28 pm
Posts: 6714
Location: Oxford, Englandshire
Collisions between circles of identical size on a 2d plane are fairly simple. If the centers of any two given circles are less than their diameter apart, they're in contact.

You can use simple trig to calculate the distance between the circles and the plane for the reflected angle that the balls will take after collision.

Adding spin might be interesting though.

_________________
10 PRINT "Bad Monkey ";
20 GOTO 10


Top
 Profile  
 
PostPosted: Wed May 11, 2011 8:50 pm 
Dexterous Droid
User avatar

Joined: Wed Aug 18, 2004 7:40 pm
Posts: 3735
Location: South Africa
Depending on how comfortable you are with Java and whether you want to do the physics calculations yourself, you could use JBox2D to make a nice billiard ball simulation. I've been using it recently and have found it works very well. The documentation is somewhat poor though. Your main resources would be:

The Box2D manual for C++ - first port of call for all functions and usage scenarios.
The JBox2D library download - look inside the src folder for the testbed code, this will be your reference for pretty much everything.
The JBox2D testbed running online as a Java applet - fun to play with :)

_________________
Whatever the mind can conceive and believe, it can achieve


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group