Esempio n. 1
0
    public void start() {
      if (paused) return;

      started = true;
      finishedFalling = false;
      turnAmount = 0;
      score = 0;
      clearBoard();

      makeNewPiece();
      timer.start();
      timer1.start();
    }
Esempio n. 2
0
    private void makeNewPiece() {
      if (!paused) {
        randNum = (int) (Math.random() * 7);
        currentX = findXCoords(randNum);
        currentY = findYCoords(randNum);
        turnAmount = 0;
        findShadow();

        boolean possibility = true;
        for (int i = 0; i < 4; i++) {
          if (!attemptMove(currentX[i], currentY[i])) {
            possibility = false;
          }
        }
        if (state != null && !possibility) {
          timer.stop();
          connection.send("KO");
          start();
        }
      }
    }
Esempio n. 3
0
    public Board() {
      setFocusable(true);
      randNum = (int) (Math.random() * 7);
      currentX = new int[4];
      currentY = new int[4];
      shadowX = new int[4];
      shadowY = new int[4];
      tempY = new int[] {0, 0, 0, 0};
      staticX = new ArrayList<Integer>();
      staticY = new ArrayList<Integer>();
      rushX = new ArrayList<Integer>();
      rushY = new ArrayList<Integer>();
      timer = new Timer(1000, this);
      timer1 = new Timer(1000, this);
      timer2 = new Timer(1000, this);
      timer2.start();
      clearBoard();

      addKeyListener(this);
      addFocusListener(this);
      addMouseListener(this);
    }