error OutsideWorld

This commit is contained in:
Leen Dereu
2018-05-22 23:23:19 +02:00
parent 817e63251a
commit c5f55f29fb

View File

@@ -80,10 +80,9 @@ public abstract class Projectile extends GameObject {
}
private double jumpVelocity() {
return getForce() / (getMass() / 1000) * FORCE_TIME;
return (getForce() / (getMass() / 1000)) * FORCE_TIME;
}
//TODO jumpTimeStep moet nog toegepast worden!
public double getJumpTime(double jumpTimeStep) {
World world = getWorld();
@@ -99,7 +98,7 @@ public abstract class Projectile extends GameObject {
Coordinate newLoc;
while (true) {
time += 0.05;
time += jumpTimeStep;
double x = loc.getX() + v * time * cos(a);
double y = loc.getY() + v * time * sin(a) - (G * time * time) / 2.0;
newLoc = Coordinate.create(x, y);
@@ -155,6 +154,7 @@ public abstract class Projectile extends GameObject {
for (Worm worm: worms) {
if (this.getDistance(worm) < 0) {
setLocation(newLocation);
hit(worm);
}
}