fixes
This commit is contained in:
@@ -3,9 +3,6 @@ package worms.model;
|
|||||||
import worms.util.Coordinate;
|
import worms.util.Coordinate;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import org.omg.PortableServer.ServantActivatorOperations;
|
|
||||||
|
|
||||||
public class World {
|
public class World {
|
||||||
|
|
||||||
@@ -191,7 +188,7 @@ public class World {
|
|||||||
double length = lengthX;
|
double length = lengthX;
|
||||||
if (lengthX > lengthY) length = lengthY;
|
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() {
|
public double getLengthX() {
|
||||||
|
@@ -559,7 +559,7 @@ public class Worm extends GameObject {
|
|||||||
double direction = getOrientation();
|
double direction = getOrientation();
|
||||||
double minDirection = direction - 0.7875;
|
double minDirection = direction - 0.7875;
|
||||||
double maxDirection = direction + 0.7875;
|
double maxDirection = direction + 0.7875;
|
||||||
double maxLocDirection = maxDirection;
|
double maxLocDirection = minDirection;
|
||||||
Coordinate maxLoc = location;
|
Coordinate maxLoc = location;
|
||||||
for (; minDirection <= maxDirection; minDirection += 0.0175) {
|
for (; minDirection <= maxDirection; minDirection += 0.0175) {
|
||||||
Coordinate tempLoc = getFurthestLocationInDirection(minDirection, this.getRadius());
|
Coordinate tempLoc = getFurthestLocationInDirection(minDirection, this.getRadius());
|
||||||
@@ -1006,44 +1006,44 @@ public class Worm extends GameObject {
|
|||||||
|
|
||||||
World world = getWorld();
|
World world = getWorld();
|
||||||
Coordinate location = getLocation();
|
Coordinate location = getLocation();
|
||||||
if (!world.isPassable(location, radius)) {
|
if (!world.isAdjacent(location, radius)) {
|
||||||
Coordinate newLoc = Coordinate.create(location.getX() + changeRadius, location.getY());
|
Coordinate newLoc = Coordinate.create(location.getX() + changeRadius, location.getY());
|
||||||
if (world.isPassable(newLoc, radius)) {
|
if (world.isAdjacent(newLoc, radius)) {
|
||||||
setLocation(newLoc);
|
setLocation(newLoc);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
newLoc = Coordinate.create(location.getX() - changeRadius, location.getY());
|
newLoc = Coordinate.create(location.getX() - changeRadius, location.getY());
|
||||||
if (world.isPassable(newLoc, radius)) {
|
if (world.isAdjacent(newLoc, radius)) {
|
||||||
setLocation(newLoc);
|
setLocation(newLoc);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
newLoc = Coordinate.create(location.getX(), location.getY() - changeRadius);
|
newLoc = Coordinate.create(location.getX(), location.getY() - changeRadius);
|
||||||
if (world.isPassable(newLoc, radius)) {
|
if (world.isAdjacent(newLoc, radius)) {
|
||||||
setLocation(newLoc);
|
setLocation(newLoc);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
newLoc = Coordinate.create(location.getX(), location.getY() + changeRadius);
|
newLoc = Coordinate.create(location.getX(), location.getY() + changeRadius);
|
||||||
if (world.isPassable(newLoc, radius)) {
|
if (world.isAdjacent(newLoc, radius)) {
|
||||||
setLocation(newLoc);
|
setLocation(newLoc);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
newLoc = Coordinate.create(location.getX() - changeRadius, location.getY() - changeRadius);
|
newLoc = Coordinate.create(location.getX() - changeRadius, location.getY() - changeRadius);
|
||||||
if (world.isPassable(newLoc, radius)) {
|
if (world.isAdjacent(newLoc, radius)) {
|
||||||
setLocation(newLoc);
|
setLocation(newLoc);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
newLoc = Coordinate.create(location.getX() + changeRadius, location.getY() + changeRadius);
|
newLoc = Coordinate.create(location.getX() + changeRadius, location.getY() + changeRadius);
|
||||||
if (world.isPassable(newLoc, radius)) {
|
if (world.isAdjacent(newLoc, radius)) {
|
||||||
setLocation(newLoc);
|
setLocation(newLoc);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
newLoc = Coordinate.create(location.getX() + changeRadius, location.getY() - changeRadius);
|
newLoc = Coordinate.create(location.getX() + changeRadius, location.getY() - changeRadius);
|
||||||
if (world.isPassable(newLoc, radius)) {
|
if (world.isAdjacent(newLoc, radius)) {
|
||||||
setLocation(newLoc);
|
setLocation(newLoc);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
newLoc = Coordinate.create(location.getX() - changeRadius, location.getY() + changeRadius);
|
newLoc = Coordinate.create(location.getX() - changeRadius, location.getY() + changeRadius);
|
||||||
if (!world.isPassable(newLoc, radius)) {
|
if (!world.isAdjacent(newLoc, radius)) {
|
||||||
terminate();
|
terminate();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user