public void processMove(Tank tank) throws InterruptedException { this.tank = tank; int i = 0; Direction tankDirection = tank.getDirection(); int tankXCoordinate = tank.getX(); int tankYCoordinate = tank.getY(); tank.turn(tankDirection); while (i < 64) { if (tankDirection == Direction.UP && tankYCoordinate > 0) { tank.updateY(-1); } if (tankDirection == Direction.DOWN && tankYCoordinate < 512) { tank.updateY(1); } if (tankDirection == Direction.LEFT && tankXCoordinate > 0) { tank.updateX(-1); } if (tankDirection == Direction.RIGHT && tankXCoordinate < 512) { tank.updateX(1); } i += 1; repaint(); Thread.sleep(tank.getSpeed()); } }
private void moveDown(Direction direction) { if (direction == Direction.DOWN) { tank.updateY(step); System.out.println( "[move down] " + "derection:" + direction + "||" + "tankX:" + tank.getX() + "||" + "tankY:" + tank.getY()); } }
private void moveUp(Direction direction) { if (direction == Direction.UP) { tank.updateY(-step); System.out.println( "[move up] " + "derection:" + direction + "||" + "tankX:" + tank.getX() + "||" + "tankY:" + tank.getY()); } }