diff --git a/OGP1718-Worms/src/worms/model/World.java b/OGP1718-Worms/src/worms/model/World.java index f842f90..ffec13a 100644 --- a/OGP1718-Worms/src/worms/model/World.java +++ b/OGP1718-Worms/src/worms/model/World.java @@ -3,9 +3,6 @@ package worms.model; import worms.util.Coordinate; import java.util.*; -import java.util.stream.Collectors; - -import org.omg.PortableServer.ServantActivatorOperations; public class World { @@ -191,7 +188,7 @@ public class World { double length = lengthX; if (lengthX > lengthY) length = lengthY; - return isPassable(center, radius) && !isPassable(center, radius + maxDistance + 0.001); + return isPassable(center, radius) && !isPassable(center, radius + maxDistance + 0.00001); } public double getLengthX() { diff --git a/OGP1718-Worms/src/worms/model/Worm.java b/OGP1718-Worms/src/worms/model/Worm.java index f338119..2422b12 100644 --- a/OGP1718-Worms/src/worms/model/Worm.java +++ b/OGP1718-Worms/src/worms/model/Worm.java @@ -566,7 +566,7 @@ public class Worm extends GameObject { double direction = getOrientation(); double minDirection = direction - 0.7875; double maxDirection = direction + 0.7875; - double maxLocDirection = maxDirection; + double maxLocDirection = minDirection; Coordinate maxLoc = location; for (; minDirection <= maxDirection; minDirection += 0.0175) { Coordinate tempLoc = getFurthestLocationInDirection(minDirection, this.getRadius()); @@ -1037,44 +1037,44 @@ public class Worm extends GameObject { World world = getWorld(); Coordinate location = getLocation(); - if (!world.isPassable(location, radius)) { + if (!world.isAdjacent(location, radius)) { Coordinate newLoc = Coordinate.create(location.getX() + changeRadius, location.getY()); - if (world.isPassable(newLoc, radius)) { + if (world.isAdjacent(newLoc, radius)) { setLocation(newLoc); return; } newLoc = Coordinate.create(location.getX() - changeRadius, location.getY()); - if (world.isPassable(newLoc, radius)) { + if (world.isAdjacent(newLoc, radius)) { setLocation(newLoc); return; } newLoc = Coordinate.create(location.getX(), location.getY() - changeRadius); - if (world.isPassable(newLoc, radius)) { + if (world.isAdjacent(newLoc, radius)) { setLocation(newLoc); return; } newLoc = Coordinate.create(location.getX(), location.getY() + changeRadius); - if (world.isPassable(newLoc, radius)) { + if (world.isAdjacent(newLoc, radius)) { setLocation(newLoc); return; } newLoc = Coordinate.create(location.getX() - changeRadius, location.getY() - changeRadius); - if (world.isPassable(newLoc, radius)) { + if (world.isAdjacent(newLoc, radius)) { setLocation(newLoc); return; } newLoc = Coordinate.create(location.getX() + changeRadius, location.getY() + changeRadius); - if (world.isPassable(newLoc, radius)) { + if (world.isAdjacent(newLoc, radius)) { setLocation(newLoc); return; } newLoc = Coordinate.create(location.getX() + changeRadius, location.getY() - changeRadius); - if (world.isPassable(newLoc, radius)) { + if (world.isAdjacent(newLoc, radius)) { setLocation(newLoc); return; } newLoc = Coordinate.create(location.getX() - changeRadius, location.getY() + changeRadius); - if (!world.isPassable(newLoc, radius)) { + if (!world.isAdjacent(newLoc, radius)) { terminate(); return; }