public void processFire(Bullet bullet) throws Exception { this.bullet = bullet; while ((bullet.getX() > -15 && bullet.getX() < battleField.getBF_WIDTH()) && (bullet.getY() > -15 && bullet.getY() < battleField.getBF_HEIGHT())) { if (bullet.getDirection() == Direction.UP) { bullet.updateY(-step); } else if (bullet.getDirection() == Direction.DOWN) { bullet.updateY(step); } else if (bullet.getDirection() == Direction.LEFT) { bullet.updateX(-step); } else { bullet.updateX(step); } if (processInterception() == true) { bullet.destroy(); } repaintFire(); } }
public ActionField() throws Exception { battleField = new BattleField(); tank = new Tank(this, battleField); agressor = new Agressor( Integer.parseInt(position.substring(0, position.indexOf("_"))), Integer.parseInt(position.substring(position.lastIndexOf("_") + 1, position.length())), Direction.LEFT, this, battleField); bullet = new Bullet(-100, -100, Direction.STOP); JFrame frame = new JFrame("BATTLE FIELD, DAY 2"); frame.setLocation(750, 150); frame.setMinimumSize( new Dimension(battleField.getBF_WIDTH() + 16, battleField.getBF_HEIGHT() + 39)); frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); frame.getContentPane().add(this); frame.pack(); frame.setVisible(true); }