コード例 #1
1
ファイル: ActionField.java プロジェクト: schukhno/src
  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());
    }
  }
コード例 #2
0
 private void repaintMove() throws InterruptedException {
   repaint();
   Thread.sleep(tank.getSpeed());
 }