Skip to content

Commit 38becbd

Browse files
committed
fix: fix random projectile speed bug
Fixed a bug in the controller that caused projectiles to be updated more than once per frame. Tweaked some base projectiles speed values.
1 parent 5bbbc7c commit 38becbd

File tree

4 files changed

+6
-7
lines changed

4 files changed

+6
-7
lines changed

src/main/java/tbooop/controller/impl/ControllerImpl.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,6 @@ private void updateGame(final long dt) {
119119
final Iterator<Projectile> projectileIterator = world.getProjectiles().iterator();
120120
while (projectileIterator.hasNext()) {
121121
final Projectile projectile = projectileIterator.next();
122-
projectile.updateState(dt);
123-
world.update();
124122
// Projectile-Entity collision
125123
if (gameObj instanceof Entity && gameObj.getCollider().isColliding(projectile.getCollider())) {
126124
projectile.onEntityCollision((Entity) gameObj);
@@ -131,6 +129,7 @@ private void updateGame(final long dt) {
131129
}
132130
}
133131
}
132+
world.getProjectiles().iterator().forEachRemaining(p -> p.updateState(dt));
134133
}
135134

136135
private void checkDoorCollision(final GameObject gameObj) {

src/main/java/tbooop/model/enemy/impl/Explosive.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
*/
1313
public class Explosive extends EnemyDecorator {
1414

15-
private static final double PROJECTILE_VELOCITY = 0.025;
15+
private static final double PROJECTILE_VELOCITY = 0.1;
1616
private final int projectileAmount;
1717
private final double shootingAngle;
1818
private boolean exploded;

src/main/java/tbooop/model/enemy/impl/Shooter.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
public class Shooter extends EnemyDecorator {
1818

1919
private static final long TIME_BETWEEN_SHOTS = 2500;
20-
private static final double PROJECTILE_VELOCITY = 0.025;
20+
private static final double PROJECTILE_VELOCITY = 0.13;
2121
private final Damageable player;
2222
private long timeSinceLastShoot;
2323

src/main/java/tbooop/model/player/impl/PlayerImpl.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
public class PlayerImpl extends AbstractPlayer {
1818

1919
private static final int TOLERANCE = 5;
20-
private static final double PROJECTILE_VELOCITY_INCREMENT = 0.005;
21-
private static final double PROJECTILE_BASE_VELOCITY = 0.11;
22-
private static final long TIME_BETWEEN_SHOTS = 300;
20+
private static final double PROJECTILE_VELOCITY_INCREMENT = 0.02;
21+
private static final double PROJECTILE_BASE_VELOCITY = 0.2;
22+
private static final long TIME_BETWEEN_SHOTS = 350;
2323
private static final long TIME_BETWEEN_DAMAGE = 300;
2424
private static final int PLAYER_INITIAL_HEALTH = 5;
2525
private static final double PLAYER_INITIAL_SPEED = 0.11;

0 commit comments

Comments
 (0)