Browse Source

cleanup and small code changes for first code homework

master
jkonert 3 years ago
parent
commit
eb21aae334
  1. 4
      GameProject/src/playground/Level4.java
  2. 4
      GameProject/src/playground/LevelBoss.java
  3. 10
      GameProject/src/playground/LevelHitTwice.java

4
GameProject/src/playground/Level4.java

@ -38,10 +38,10 @@ public class Level4 extends SpaceInvadersLevel {
if (counter >= MAX_HITS) {
logger.trace("enemy was hit before for " + counter + " times, which is above "
+ HitTwiceLevel.MAX_HITS);
+ LevelHitTwice.MAX_HITS);
super.actionIfEnemyIsHit(e, shot);
} else {
logger.trace("enemy was hit before for "+counter+" times, which is below "+HitTwiceLevel.MAX_HITS);
logger.trace("enemy was hit before for "+counter+" times, which is below "+LevelHitTwice.MAX_HITS);
e.setObjectFlag("counter", Integer.valueOf(counter + 1));
// spawn a bonus points object
double vx = 2 * (Math.random() - 0.5) * SHARDSPEED + e.getVX();

4
GameProject/src/playground/LevelBoss.java

@ -37,11 +37,11 @@ public class LevelBoss extends SpaceInvadersLevel {
if (counter >= LevelBoss.MAX_SHOTS) {
logger.trace("enemy was hit before for " + counter + " times, which is equal or above "
+ HitTwiceLevel.MAX_HITS);
+ LevelHitTwice.MAX_HITS);
super.actionIfEnemyIsHit(e, shot);
} else {
logger.trace("enemy was hit before for " + counter + " times, which is below "
+ HitTwiceLevel.MAX_HITS);
+ LevelHitTwice.MAX_HITS);
e.setObjectFlag("counter", Integer.valueOf(counter + 1));
}
deleteObject(shot.getId());

10
GameProject/src/playground/HitTwiceLevel.java → GameProject/src/playground/LevelHitTwice.java

@ -17,15 +17,15 @@ import org.apache.logging.log4j.Logger;
*/
public class HitTwiceLevel extends SpaceInvadersLevel {
public class LevelHitTwice extends SpaceInvadersLevel {
/** constant defining the number of shots needed to destroy an enemy */
public static final int MAX_HITS = 2;
private static Logger logger = LogManager.getLogger(HitTwiceLevel.class);
private static Logger logger = LogManager.getLogger(LevelHitTwice.class);
/** constructor setting internal name to 'hitTwice' */
public HitTwiceLevel() {
public LevelHitTwice() {
super();
this.level = "hitTwice";
}
@ -59,10 +59,10 @@ public class HitTwiceLevel extends SpaceInvadersLevel {
if (counter >= MAX_HITS) {
logger.trace("enemy was hit before for " + counter + " times, which is above "
+ HitTwiceLevel.MAX_HITS);
+ LevelHitTwice.MAX_HITS);
super.actionIfEnemyIsHit(e, shot);
} else {
logger.trace("enemy was hit before for "+counter+" times, which is below "+HitTwiceLevel.MAX_HITS);
logger.trace("enemy was hit before for "+counter+" times, which is below "+LevelHitTwice.MAX_HITS);
e.setObjectFlag("counter", Integer.valueOf(counter + 1));
}
deleteObject(shot.getId());
Loading…
Cancel
Save