Errors oplossen
This commit is contained in:
@@ -83,13 +83,19 @@ public abstract class Projectile extends GameObject {
|
||||
private double jumpVelocity() {
|
||||
return getForce() / (getMass() / 1000) * FORCE_TIME;
|
||||
}
|
||||
|
||||
|
||||
//TODO jumpTimeStep moet nog toegepast worden!
|
||||
public double getJumpTime(double jumpTimeStep) {
|
||||
double v = jumpVelocity();
|
||||
double time = jumpTimeStep;
|
||||
World world = getWorld();
|
||||
|
||||
if (world == null) {
|
||||
throw new IllegalStateException("World cannot be null");
|
||||
}
|
||||
|
||||
double v = jumpVelocity();
|
||||
double time = 0;
|
||||
double a = getOrientation();
|
||||
Coordinate loc = getLocation();
|
||||
World world = getWorld();
|
||||
double radius = getRadius();
|
||||
Coordinate newLoc;
|
||||
|
||||
@@ -104,6 +110,7 @@ public abstract class Projectile extends GameObject {
|
||||
newLoc = Coordinate.create(loc.getX() + v * time * cos(a), loc.getY() + v * time * sin(a) - (G * time * time) / 2.0);
|
||||
if (newLoc.getX() < 0 || newLoc.getY() < 0 || newLoc.getX() > getWorld().getWidth() ||
|
||||
newLoc.getY() > world.getHeight() || world.isAdjacent(newLoc, radius)) {
|
||||
if (getDistance(loc, newLoc) < getRadius()) throw new IllegalStateException();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -115,8 +122,14 @@ public abstract class Projectile extends GameObject {
|
||||
}
|
||||
return time;
|
||||
}
|
||||
|
||||
private boolean canJump() {
|
||||
|
||||
public double getDistance(Coordinate start, Coordinate end) {
|
||||
return Math.sqrt(Math.pow(Math.abs(start.getX() - end.getX()), 2) +
|
||||
Math.pow(Math.abs(start.getY() - end.getY()), 2));
|
||||
}
|
||||
|
||||
|
||||
private boolean canJump() {
|
||||
return getOrientation() < PI;
|
||||
}
|
||||
|
||||
|
@@ -2439,8 +2439,6 @@ public class Part3_FullFacadeTest {
|
||||
double[] expectedBazookaLocation = new double[] { 6.114, 3.875 };
|
||||
System.out.println(projectile instanceof Rifle);
|
||||
assertEquals("Result must have exactly 2 coordinates", 2, stepLocation.length);
|
||||
System.out.println(stepLocation[0] + " " + stepLocation[1]);
|
||||
System.out.println(projectile.getLocationArray()[0] + " " + projectile.getLocationArray()[1]);
|
||||
assertTrue((Math.abs(stepLocation[0] - expectedRifleLocation[0]) < 0.01)
|
||||
|| (Math.abs(stepLocation[0] - expectedBazookaLocation[0]) < 0.01));
|
||||
assertTrue((Math.abs(stepLocation[1] - expectedRifleLocation[1]) < 0.01)
|
||||
|
Reference in New Issue
Block a user