Merge branch 'master' of gitlab.principis.be:OGP/worms

This commit is contained in:
2018-05-22 15:42:15 +02:00
2 changed files with 11 additions and 7 deletions

View File

@@ -4,6 +4,8 @@ import static java.lang.Math.*;
import worms.util.Coordinate;
import java.util.List;
public abstract class Projectile extends GameObject {
private static final int rho = 7800;
@@ -111,7 +113,6 @@ public abstract class Projectile extends GameObject {
throw new RuntimeException();
}
}
return time;
}
@@ -128,9 +129,15 @@ public abstract class Projectile extends GameObject {
double a = getOrientation();
Coordinate newLocation;
List<Worm> worms = getWorld().getGameObjectsByClass(Worm.class);
for (Worm worm: worms) {
if (this.getDistance(worm) < 0) {
newLocation = Coordinate.create(getLocation().getX(), getLocation().getY());
setLocation(newLocation);
}
}
//TODO In case the initial position of a projectile already hits impassable terrain or a worm, the projectile will
//TODO jump over a distance of 0.0 m.
if (getWorld().isAdjacent(getLocation(),getRadius())) {
newLocation = Coordinate.create(getLocation().getX(), getLocation().getY());
}

View File

@@ -1227,9 +1227,6 @@ public class Worm extends GameObject {
public Projectile fire() {
if (canFire()) {
//TODO location overlaps with 1 or more projectiles => firing worm is hit by one overlapping projectile
//TODO => method returns null
if (!getWorld().getGameObjectsByClass(Projectile.class).isEmpty()) {
List<Projectile> projectiles = getWorld().getGameObjectsByClass(Projectile.class);
for (Projectile project: projectiles) {