Package playground

Class LevelHitTwice


public class LevelHitTwice extends SpaceInvadersLevel
extends SpaceInvadersLevel with 10 enemies that need two shots each to be destroyed.
  • Field Details

    • MAX_HITS

      public static final int MAX_HITS
      constant defining the number of shots needed to destroy an enemy
      See Also:
  • Constructor Details

    • LevelHitTwice

      public LevelHitTwice()
      constructor setting internal name to 'hitTwice'
  • Method Details

    • getStartupMessage

      protected String getStartupMessage()
      Description copied from class: SpaceInvadersLevel
      simply returns the text that should be displayed at level start
      Overrides:
      getStartupMessage in class SpaceInvadersLevel
      Returns:
      a string that is displayed at start. Should be not longer than 30 characters.
    • calcNrEnemies

      protected int calcNrEnemies()
      Description copied from class: SpaceInvadersLevel
      returns the maximum number of enemy instances (which are created at level start)
      Overrides:
      calcNrEnemies in class SpaceInvadersLevel
      Returns:
      a positive value
    • actionIfEnemyIsHit

      void actionIfEnemyIsHit(GameObject e, GameObject shot)
      Description copied from class: SpaceInvadersLevel
      implements game behavior if an enemy object is hit by a players' shot. It creates an explosion effect, plays a sound and adds 200 points to the current score (and it removes the enemy object and the shot object).
      Overrides:
      actionIfEnemyIsHit in class SpaceInvadersLevel
      Parameters:
      e - enemy which was hit
      shot - the shot object that hit the enemy