My favorites | Sign in
Project Home Wiki Issues Source
READ-ONLY: This project has been archived. For more information see this post.
Search
for
  Advanced search   Search tips   Subscriptions
Issue 2: Some asteroids escape the force field
1 person starred this issue and may be notified of changes. Back to list
Status:  Accepted
Owner:  maksym.morawski


 
Project Member Reported by maksym.morawski, Jun 17, 2012
A good example of this is if you knock the force field away, stationary asteroids will ALWAYS escape.  Also a pulse right on the edge will cause asteroids to escape.  Reason for this is unknown.
Jun 18, 2012
Project Member #1 apsill...@gmail.com
The reason for this could be that the magnitude the asteroid's movement vector allows it to hop over the force field.  Add the clause `|| s instanceof Ship` to the first conditional in AsteroidForceField.collide and you'll see that the ship can escape quite readily after only a few tries.
Jun 19, 2012
Project Member #2 apsill...@gmail.com
Okay, he's the problem:

!inner.contains(new Point2D.Double(s.getX() + s.getXVel(), s.getY() + s.getYVel()))

This line is trying to test if the object is about to exit the force field, but it's not quite right. Currently, it tests if the velocity of the object at *this time tick* is sufficient to launch it out of the circle.  Sometimes, this check turns out to be false, and then on the next tick, the object accelerates to a higher velocity than it had at the previous time tick, which allows it to escape the force field.

Solving this problem is non-trivial: we either need to 1) calculate the velocity that the object will have at the next time tick, or 2) perform our collision testing just after velocities are calculated and just before the objects are moved.

Powered by Google Project Hosting