Errors projectile

This commit is contained in:
Leen Dereu
2018-05-22 22:08:19 +02:00
parent 5e9c6b25d9
commit 12defdc769
3 changed files with 11 additions and 4 deletions

View File

@@ -26,6 +26,8 @@ public class Bazooka extends Projectile {
if (value == 0) value++;
else value--;
}
double force = getForce();
value = value* (int) force;
super.hitPoints = value;
}

View File

@@ -82,8 +82,7 @@ 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) {
World world = getWorld();
@@ -105,7 +104,7 @@ public abstract class Projectile extends GameObject {
newLoc = Coordinate.create(x, y);
if (! world.isPassable(newLoc, radius) || x < 0 || y < 0 || x > world.getWidth() || y > world.getHeight()) {
while (true) {
time -= 0.01;
time -= jumpTimeStep;
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)) {
@@ -161,7 +160,14 @@ public abstract class Projectile extends GameObject {
terminate();
return;
}
setLocation(newLocation);
for (Worm worm: worms) {
if (this.getDistance(worm) < 0) {
hit(worm);
}
}
}
private static Coordinate calcLocation(Coordinate wormLocation, double wormOrientation, double wormRadius, double mass) {