Marshmallow has a very close (to the decimal percentage) relation between virtual bullet hit ratio and real bullet hit ratio. This might or might not be common. Here's the relevant code anyway:
private Point2D enemyLocation;
private Point2D bulletLocation;
private Ellipse2D vincinity = new Ellipse2D.Double();
private double precision = 20.0;
...
boolean hasHit() {
...
vincinity.setFrameFromCenter(enemyLocation,
new Point2D.Double(enemyLocation.getX() - precision, enemyLocation.getY() - precision));
if (vincinity.contains(bulletLocation)) {
...
return true;
}
else {
return false;
}
}
The code not shown isn't TopSecret? as such, its just not relevant to the example. Feel free to use this code. Give me credit if you think I deserve it. -- PEZ