Results 1 to 4 of 4
  1. #1
    prashant is offline Member
    Join Date
    Dec 2008
    Rep Power

    Question Collision Detection for Billiards game

    Hi guys,
    I want to develop a Billiards game in Java.
    I want know methods for detecting Ball-to-Ball collision & further how to deal on a collision?
    Please help me guys.

    Thank you.

  2. #2
    Join Date
    May 2011
    Rep Power


    Is this developing in Java2D?

    tricky. Maybe create some Ball objects which render to Ovals in the Graphics2D context.

    You would have a thread for each ball. Each update of the trajectory should update the painting of the component.

    In order to detect 'hits' with other balls, you would have to convert to ellipses to area objects and then see if there are any conflicts.


    If there are then you need to do a whole lot of trigonomtry maths to figure out the new path.
    read my blog :

  3. #3
    Join Date
    Apr 2011
    Rep Power


    All I can say is arrays.

  4. #4
    rdjava's Avatar
    rdjava is offline Member
    Join Date
    Jan 2011
    Rep Power


    This kind of collision can be called the Circle to Circle Collision, where the distance of both circle's centers are equal or less than the sum of both radii.

    the distance formula is the equation to use
    D = Math.sqrt( Math.pow(x1 - x2) + Math.pow(y1 - y2) );
    this is actually not a great way to do this equation
    so you just make it so you don't use Math objects

    ((x1 - x2) * (x1 - x2)) + ((y1 + y2) * (y1 + y2)) <= ((radius1 + radius2) * (radius1 + radius2))

    However, you may want to also look at 2D elastic collisions for accurate collision with 2D physics

Similar Threads

  1. Java3D collision detection
    By abbeywell in forum Java Gaming
    Replies: 5
    Last Post: 04-27-2011, 03:33 PM
  2. Let's Check My Collision Detection Algorithm
    By Revenna in forum Java 2D
    Replies: 3
    Last Post: 03-23-2011, 03:44 PM
  3. Really Need help with some collision detection
    By Harwad in forum New To Java
    Replies: 1
    Last Post: 01-23-2011, 01:38 AM
  4. Collision Detection
    By dotabyss in forum Java Gaming
    Replies: 0
    Last Post: 03-14-2010, 07:13 PM
  5. Collision Detection (Game)
    By mscwd in forum Sun Java Wireless Toolkit
    Replies: 0
    Last Post: 01-28-2008, 09:34 PM

Posting Permissions

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