Results 1 to 4 of 4
- 05-09-2011, 02:16 PM #1
Member
- Join Date
- Dec 2008
- Posts
- 15
- Rep Power
- 0
- 05-09-2011, 02:27 PM #2
Member
- Join Date
- May 2011
- Location
- Munich
- Posts
- 15
- Rep Power
- 0
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.
area1.intersect(area2);
If there are then you need to do a whole lot of trigonomtry maths to figure out the new path.read my blog : www.blue-walrus.com
- 05-21-2011, 03:52 AM #3
All I can say is arrays.
<Daniel>P.</Berry>
- 06-02-2011, 04:45 AM #4
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
-
Java3D collision detection
By abbeywell in forum Java GamingReplies: 5Last Post: 04-27-2011, 02:33 PM -
Let's Check My Collision Detection Algorithm
By Revenna in forum Java 2DReplies: 3Last Post: 03-23-2011, 02:44 PM -
Really Need help with some collision detection
By Harwad in forum New To JavaReplies: 1Last Post: 01-23-2011, 12:38 AM -
Collision Detection
By dotabyss in forum Java GamingReplies: 0Last Post: 03-14-2010, 06:13 PM -
Collision Detection (Game)
By mscwd in forum Sun Java Wireless ToolkitReplies: 0Last Post: 01-28-2008, 08:34 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks