OZONE Asylum
Forums
DHTML/Javascript
Pinball game: Collision of a ball with a pinball paddle
This page's ID:
30777
Search
QuickChanges
Forums
FAQ
Archives
Register
Edit Post
Who can edit a post?
The poster and administrators may edit a post. The poster can only edit it for a short while after the initial post.
Your User Name:
Your Password:
Login Options:
Remember Me On This Computer
Your Text:
Insert Slimies »
Insert UBB Code »
Close
Last Tag
|
All Tags
UBB Help
I found this hit test but I have some questions. From looking at similar scripts before, I think float means a non integer variable. Is that correct? I don't have the first clue. Is this the test I need to build or something similar. It looks like it to me, but I really can't be sure. From this link http://ubuntu-gamedev.wikispaces.com/2D+Collision+Detection Circle in Triangle Using the halfspace methodology gets a little trickier when comparing two areas. This is mainly because the halfspace test can only check a line vs a point, and an area has an infinite number of points that exist inside of it. So in addition to using the ability of the halfspace tests to check whether the area is on a certain side, we must also check how far away from that side it is. The circle is the easiest thing to check against in this way, since it has a constant distance from its center. [code] bool circleInTriangle2d(float* a, float* b, float* c, float* center, float radius) { // if clockwise, make it counter-clockwise if(inLeftHalfspace2d(b,a,c)) { float* temp = a; a = b; b = temp; } float away[2],awayPos[2]; // The first edge if(inLeftHalfspace2d(a,b,center)) { sub_2d_vector(b,a,away); quarterLeft2d(away,away); add_2d_vector(a,away,awayPos); if(inLeftHalfspace2d(awayPos,a,center)) { add_2d_vector(b,away,awayPos); if(inLeftHalfspace2d(awayPos,b,center)) { sub_2d_vector(center,b,awayPos); return component2d(away,awayPos) > radius; } return inCircle2d(center,radius,b); } return inCircle2d(center,radius,a); } // The second edge if(inLeftHalfspace2d(b,c,center)) { sub_2d_vector(c,b,away); quarterLeft2d(away,away); add_2d_vector(b,away,awayPos); if(inLeftHalfspace2d(awayPos,b,center)) { add_2d_vector(c,away,awayPos); if(inLeftHalfspace2d(awayPos,c,center)) { sub_2d_vector(center,c,awayPos); return component2d(away,awayPos) > radius; } return inCircle2d(center,radius,c); } return inCircle2d(center,radius,b); } // The third edge if(inLeftHalfspace2d(c,a,center)) { sub_2d_vector(c,a,away); quarterLeft2d(away,away); add_2d_vector(c,away,awayPos); if(inLeftHalfspace2d(awayPos,c,center)) { add_2d_vector(a,away,awayPos); if(inLeftHalfspace2d(awayPos,a,center)) { sub_2d_vector(center,a,awayPos); return component2d(away,awayPos) > radius; } return inCircle2d(center,radius,a); } return inCircle2d(center,radius,c); } // the center is inside the triangle, so the circle is colliding return true; } [/code]
Loading...
Options:
Enable Slimies
Enable Linkwords
« Backwards
—
Onwards »