This site requires JavaScript, please enable it in your browser!
Greenfoot back
BrownBoii333
BrownBoii333 wrote ...

2014/11/19

Falls bouncing off at angles

BrownBoii333 BrownBoii333

2014/11/19

#
Hi I'm making a pool game and I need to know how to make balls bounce of of angled edges. My code for regular horizontal or vertical edges is just getMovement().revertVertical(), and getMovement().revertHorizontal(). but you know how in pool near the pockets the edge is angles right? Due to this the ball just bouncing as if hitting a normal horizontal or vertical wall rather than a diagonal one. Actor h = (Actor)getOneIntersectingObject(HorizEdge.class); Actor v = (Actor)getOneIntersectingObject(VertEdge.class); if(h!=null){ getMovement().revertVertical(); }else if(v!=null){ getMovement().revertHorizontal(); } I need help please
danpost danpost

2014/11/19

#
The formula is that the resultant angular vector will be twice the angle of the rail minus the initial angular vector. The length of the vector should be the same value (under perfect conditions).
BrownBoii333 BrownBoii333

2014/11/19

#
So how would i code that though?
danpost danpost

2014/11/19

#
That all depends on what code you already have for the movement (methods available, how movement values are retained, etc.).
You need to login to post a reply.