And then it works... mostly.
To reset the BouncingBall at a random trajectory, onMouseDown() in the
Big Black Circle.
The operative function is:
VR = -VR; // VR starts as the old trajectory
VR.angle = VectorRay.angle - VectorRay.getDirectedAngle(VR); // and
here it's the new
// VectorRay is the Ray/Line from Perimeter to Center at Point of
impact.
I won't say I understand this, as it was a lot of plug and chug. But I
understand it enough so to chug in the right direction.
It's not perfect as it treats the walls of the OctoGon as if it were a
circle. (Yeah, I just realized this.) But good enough for this project.
And then, after letting it run for awhile (and checking back), I found
that the BouncingBall had disappeared. So, there might be other bugs,
but at least one that I know of is that at the OctoGon corners, the ball sometimes wiggles through.
Previous Brett Code Index Next in Series
Copyright © 2013 Brett Paufler