fix ispassable

This commit is contained in:
2018-04-13 16:12:45 +02:00
parent 262e652dee
commit c0be2de7c1
3 changed files with 15 additions and 9 deletions

View File

@@ -1,6 +1,5 @@
package worms.facade;
import com.sun.org.apache.xpath.internal.operations.Mod;
import worms.model.Food;
import worms.model.Team;
import worms.model.World;

View File

@@ -142,13 +142,21 @@ public class World {
public boolean isPassable(double[] center, double radius) {
for (double i = 0; i < 2 * Math.PI; i += Math.PI / 180) {
double lenX = center[0] + radius * Math.cos(i);
double lenY = center[1] + radius * Math.sin(i);
double lenX = Math.round((center[0] + radius * Math.cos(i)) * 10000) / 10000;
double lenY = Math.round((center[1] + radius * Math.sin(i)) * 10000) / 10000;
if (!isPassable(lenX, lenY)) return false;
if (i < 1.58 && i > 1.57) {
lenY -= 0.00001;
}
else if (i < 0.79 && i > 0.78 ) {
lenX -= 0.00001;
}
if (!isPassable(lenX, lenY)) {
return false;
}
}
return true;
}
private boolean isUnderCircle(Coordinate square, Coordinate center, double radius) {

View File

@@ -56,7 +56,6 @@ public class PartialPart2FacadeTest {
assertEquals(1, xy[0], EPS);
assertEquals(2.0, xy[1], EPS);
}
@Test
public void testFall() {
// . X .