aanpassen Projectile
This commit is contained in:
@@ -69,7 +69,6 @@ public abstract class Projectile extends GameObject {
|
|||||||
public static final double FORCE_TIME = 0.5;
|
public static final double FORCE_TIME = 0.5;
|
||||||
|
|
||||||
public Coordinate getJumpStep(double elapsedTime) {
|
public Coordinate getJumpStep(double elapsedTime) {
|
||||||
// TODO zie naar worm hoe dit moet, implementatie moet wel anders!
|
|
||||||
if (Double.isNaN(elapsedTime) || elapsedTime > this.getJumpTime(elapsedTime) || elapsedTime < 0)
|
if (Double.isNaN(elapsedTime) || elapsedTime > this.getJumpTime(elapsedTime) || elapsedTime < 0)
|
||||||
throw new IllegalArgumentException();
|
throw new IllegalArgumentException();
|
||||||
|
|
||||||
@@ -84,7 +83,6 @@ public abstract class Projectile extends GameObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private double getJumpTime(double jumpTimeStep) {
|
private double getJumpTime(double jumpTimeStep) {
|
||||||
// TODO zie naar worm hoe dit moet, implementatie moet wel anders!
|
|
||||||
double v = jumpVelocity();
|
double v = jumpVelocity();
|
||||||
double time = jumpTimeStep;
|
double time = jumpTimeStep;
|
||||||
double a = getOrientation();
|
double a = getOrientation();
|
||||||
@@ -122,7 +120,6 @@ public abstract class Projectile extends GameObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void jump(double jumpTimeStep) throws IllegalStateException {
|
public void jump(double jumpTimeStep) throws IllegalStateException {
|
||||||
// TODO zie naar worm hoe dit moet, implementatie moet wel anders!
|
|
||||||
if (!canJump())
|
if (!canJump())
|
||||||
throw new IllegalStateException();
|
throw new IllegalStateException();
|
||||||
|
|
||||||
@@ -132,10 +129,9 @@ public abstract class Projectile extends GameObject {
|
|||||||
Coordinate newLocation;
|
Coordinate newLocation;
|
||||||
|
|
||||||
|
|
||||||
//TODO extra parameter if: als de worm die wil schieten tegen een andere worm staat
|
//TODO extra parameter if: als de worm die wil schieten tegen een andere worm staat:
|
||||||
//
|
//TODO In case the initial position of a projectile already hits impassable terrain or a worm, the projectile will
|
||||||
//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.
|
||||||
//jump over a distance of 0.0 m.
|
|
||||||
if (getWorld().isAdjacent(getLocation(),getRadius())) {
|
if (getWorld().isAdjacent(getLocation(),getRadius())) {
|
||||||
newLocation = Coordinate.create(getLocation().getX(), getLocation().getY());
|
newLocation = Coordinate.create(getLocation().getX(), getLocation().getY());
|
||||||
}
|
}
|
||||||
@@ -156,4 +152,13 @@ public abstract class Projectile extends GameObject {
|
|||||||
return Coordinate.create(wormLocation.getX() + cos(wormOrientation) * (wormRadius + radius),
|
return Coordinate.create(wormLocation.getX() + cos(wormOrientation) * (wormRadius + radius),
|
||||||
wormLocation.getY() + sin(wormOrientation) * (wormRadius + radius));
|
wormLocation.getY() + sin(wormOrientation) * (wormRadius + radius));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO hit impassable terrain (adjacent, partly or complete): projectile stays at that position
|
||||||
|
public void hit(Worm... worm){
|
||||||
|
for (Worm wormA : worm){
|
||||||
|
//TODO bazooka: hitpoints multiplied with force?
|
||||||
|
wormA.decreaseHitPoints(getHitPoints());
|
||||||
|
}
|
||||||
|
terminate();
|
||||||
|
}
|
||||||
}
|
}
|
@@ -1212,14 +1212,12 @@ public class Worm extends GameObject {
|
|||||||
// region firing and projectiles
|
// region firing and projectiles
|
||||||
//===================================================================================
|
//===================================================================================
|
||||||
|
|
||||||
private double[] locationProj;
|
|
||||||
private double massProj;
|
|
||||||
private long hitpointsProj;
|
|
||||||
private double forceProj;
|
|
||||||
|
|
||||||
public Projectile fire() {
|
public Projectile fire() {
|
||||||
if (canFire()) {
|
if (canFire()) {
|
||||||
|
|
||||||
|
//TODO location overlaps with 1 or more projectiles => firing worm is hit by one overlapping projectile
|
||||||
|
//TODO => method returns null
|
||||||
|
|
||||||
int random = ThreadLocalRandom.current().nextInt(2);
|
int random = ThreadLocalRandom.current().nextInt(2);
|
||||||
|
|
||||||
if (random == 0) {
|
if (random == 0) {
|
||||||
@@ -1240,17 +1238,6 @@ public class Worm extends GameObject {
|
|||||||
return getActionPoints() >= 30 && getWorld() != null;
|
return getActionPoints() >= 30 && getWorld() != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// public void hitByRifle() {
|
|
||||||
// decreaseHitPoints(hitpointsProj);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public void hitByBazooka() {
|
|
||||||
// decreaseHitPoints(hitpointsProj * (long) forceProj);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// TODO We gaan maar 1 hit function gebruiken
|
|
||||||
|
|
||||||
|
|
||||||
// ===================================================================================
|
// ===================================================================================
|
||||||
// endregion
|
// endregion
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user