public void initResources() {
    super.initResources();

    Resources.loadInt("Height", HEIGHT);
    Resources.loadInt("Width", WIDTH);

    initControls();
  }
  public void checkLevelStatus() {
    if (!humanPlayer.isActive()) {
      game.playSound(Resources.getSound("explosion"));
      game.gameOver();
    } else if (!computerPlayer.isActive()) {
      game.playSound(Resources.getSound("explosion"));
      currentLevel++;
      currentScore.setStat(currentScore.getStat() + 10);
      deployLevel(currentLevel);
    }

    if (humanPlayer.isPaused()) {
      humanPlayer.invokePause();
      game.togglePauseGame();
    }
  }
 public MenuState(Blah aGame) {
   game = aGame;
   menuOverlay = new OverlayString("Press Space to Start", Color.CYAN);
   menuOverlay.setLocation(TEXT_X_POSITION, TEXT_Y_POSITION);
   playField = new PlayField();
   playField.setBackground(new ImageBackground(Resources.getImage("titleBackground")));
 }
 public BetterSprite fireTopBeam() {
   BetterSprite beam =
       new BetterSprite(
           Resources.getImage("reacherBeamImage"),
           this.getX(),
           this.getY() + this.getHeight() / 7);
   beam.setHorizontalSpeed(-REACHER_BEAM_SPEED);
   fireTopBeamTimer = new Timer(REACHER_BEAM_RELOAD_TIME);
   topBeamReloaded = false;
   return beam;
 }
 /**
  * Depletes the health of Reacher. Reacher's shield level is controlled by the number of
  * ReacherEyes still active.
  *
  * @param depleteAmount
  * @return Has Reacher been destroyed?
  */
 public boolean deplete(int depleteAmount) {
   if (!this.isVulnerable()) {
     return false;
   }
   // this.health -= depleteAmount;
   this.setHealth(getHealth() - depleteAmount);
   if (getHealth() <= 0) {
     return true;
   } else if (getHealth() >= breakpoints[0]) {
     // this.setImages(new BufferedImage[]{Resources.getAnimation("reacherAnimation")[3]});
     this.setImage(Resources.getAnimation("reacherAnimation")[3]);
   } else if (getHealth() >= breakpoints[1]) {
     // this.setImages(new BufferedImage[]{Resources.getAnimation("Reacher")[4]});
     this.setImage(Resources.getAnimation("reacherAnimation")[4]);
   } else {
     // this.setImages(new BufferedImage[]{Resources.getAnimation("Reacher")[5]});
     this.setImage(Resources.getAnimation("reacherAnimation")[5]);
   }
   return false;
 }
 public BetterSprite fireRedRay() {
   BetterSprite redray =
       new BetterSprite(
           Resources.getImage("reacherRedRayImage"),
           this.getX() + this.getWidth() / 4,
           this.getY() + 3 * this.getHeight() / 7);
   redray.setHorizontalSpeed(-REACHER_REDRAY_SPEED);
   fireRedRayTimer = new Timer(REACHER_REDRAY_RELOAD_TIME);
   redRayReloaded = false;
   return redray;
 }
  public void initializePlayers() {

    Sprite humanSprite =
        new Sprite(
            Resources.getImage("humanPlayer"),
            humanPlayerStartingLocation.x,
            humanPlayerStartingLocation.y);
    Sprite computerSprite =
        new Sprite(
            Resources.getImage("computerPlayer"),
            computerPlayerStartingLocation.x,
            computerPlayerStartingLocation.y);

    humanPlayer = new CyclePlayer("humanPlayer", humanSprite);

    computerPlayer = new CyclePlayer("computerPlayer", computerSprite);

    resetPlayers();

    keyboardControl = new KeyboardControl(humanPlayer, game);
    keyboardControl =
        humanPlayer.addPlayerControl(
            keyboardControl, KeyEvent.VK_UP, KeyEvent.VK_DOWN, KeyEvent.VK_LEFT, KeyEvent.VK_RIGHT);
  }
 public void initLevelManager() {
   levelManager = new LevelManager(this);
   String levelFilesDirectory = Resources.getString("levelFilesDirectory");
   String levelNamesFile = Resources.getString("levelNamesFile");
   levelManager.makeLevels(levelFilesDirectory, levelNamesFile);
 }
  public void loadTiles(File file) throws IOException {
    ArrayList<String> lines = new ArrayList<String>();
    width = 0;
    height = 0;

    if (file == null) {
      throw new IOException("No such map!");
    }

    // read every line in the text file into the list
    BufferedReader reader = new BufferedReader(new FileReader(file));

    while (true) {
      String line = reader.readLine();
      // no more lines to read
      if (line == null) {
        reader.close();
        break;
      }
      // add every line except for comments
      if (!line.startsWith("#")) {
        lines.add(line);
        width = Math.max(width, line.length());
      }
    }

    // parse the lines to create a tile list
    Character curChar = ' ';
    height = lines.size();
    for (int j = 0; j < width; j++) {
      for (int k = 0; k < height; k++) {
        double x = tilesToPixels(j);
        double y = tilesToPixels(k);
        curChar = (j < lines.get(k).length()) ? lines.get(k).charAt(j) : ' ';
        switch (curChar) {
          case (' '):
            break;
          case ('F'):
            addTile(new IndestructibleTile(x, y, Resources.getImage("GrassTile")));
            break;
          case ('D'):
            addTile(new IndestructibleTile(x, y, Resources.getImage("DirtTile")));
            break;
          case ('B'):
            addTile(new BreakTile(x, y, Resources.getImage("Break")));
            break;
          case ('C'):
            List<BufferedImage> changingImages = new ArrayList<BufferedImage>();
            changingImages.add(Resources.getImage("Changing1"));
            changingImages.add(Resources.getImage("Changing2"));
            changingImages.add(Resources.getImage("Changing3"));
            changingImages.add(Resources.getImage("Changing4"));
            addTile(new ChangingTile(x, y, changingImages));
            break;
          case ('G'):
            List<BufferedImage> itemTileImages = new ArrayList<BufferedImage>();
            itemTileImages.add(Resources.getImage("ItemTile1"));
            itemTileImages.add(Resources.getImage("ItemTile2"));
            GravityItem gravityItem =
                new GravityItem(new Sprite(Resources.getImage("GravityItem")), .5);
            gravityItem.setLocation(
                x + (TILE_SIZE - gravityItem.getWidth()) / 2, y - gravityItem.getHeight());
            addTile(new ItemTile(x, y, itemTileImages, gravityItem));
            break;
          case ('S'):
            List<BufferedImage> coinTileImages = new ArrayList<BufferedImage>();
            coinTileImages.add(Resources.getImage("ItemTile1"));
            coinTileImages.add(Resources.getImage("ItemTile2"));
            Coin coin = new Coin(new Sprite(Resources.getImage("Coin")));
            coin.setLocation(x + (TILE_SIZE - coin.getWidth()) / 2, y - coin.getHeight());
            addTile(new CoinTile(x, y, coinTileImages, coin));
            break;
        }
      }
    }
  }