示例#1
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();
        }
      }
    }
示例#2
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);
    }