Beispiel #1
0
  public static void clickHWall(BoardGui frame, Robot bot, Board board, int sectNum) {
    int xInstersectOffset = 7;
    int yInstersectOffset = 51;
    // Rest for a little while
    try {
      Thread.sleep(900, 000);
    } catch (InterruptedException e) {
    }

    // Intersects
    bot.mouseMove(
        frame.sect.get(sectNum).getX() + xInstersectOffset,
        frame.sect.get(sectNum).getY() + yInstersectOffset);

    bot.mousePress(InputEvent.BUTTON1_MASK);
    // add time between press and release or the input event system may
    // not think it is a click
    try {
      Thread.sleep(250);
    } catch (InterruptedException e) {
    }
    bot.mouseRelease(InputEvent.BUTTON1_MASK);

    try {
      Thread.sleep(250);
    } catch (InterruptedException e) {
    }
    frame.submitHWall();

    frame.labels[board.getCurrPlayer()].setText(
        "\t\t\t " + board.getWallCount(board.getCurrPlayer()) + " walls remain");
    frame.labels[board.getCurrPlayer()].repaint();

    frame.control.iteratePlayers(board, board.getPlayerCount());
  }
Beispiel #2
0
  /** @author David Rice This is the main for the Quoridor game */
  public static void main(String[] args) throws AWTException {

    Board board = new Board(2);

    board.setCurrPlayer(0);

    BoardGui frame = new BoardGui(board.getPlayerCount(), board.getCurrPlayer(), board);
    frame.setSize(700, 410);
    frame.setResizable(false);
    frame.setVisible(true);

    /*
    Robot bot = new Robot();

    // Rest for a little while
    try{Thread.sleep(900,000);}catch(InterruptedException e){}
    clickSpace(frame, bot, board, 3);

    clickHWall(frame, bot, board, 17);

    clickVWall(frame, bot, board, 10);
    */
  }
Beispiel #3
0
  public static void clickSpace(BoardGui frame, Robot bot, Board board, int space) {
    int xButtonOffset = 16;
    int yButtonOffset = 63;
    // Rest for a little while
    try {
      Thread.sleep(900, 000);
    } catch (InterruptedException e) {
    }
    // Spaces
    bot.mouseMove(
        frame.space.get(space).getX() + xButtonOffset,
        frame.space.get(space).getY() + yButtonOffset);

    bot.mousePress(InputEvent.BUTTON1_MASK);
    // add time between press and release or the input event system may
    // not think it is a click
    try {
      Thread.sleep(250);
    } catch (InterruptedException e) {
    }
    bot.mouseRelease(InputEvent.BUTTON1_MASK);

    frame.control.iteratePlayers(board, board.getPlayerCount());
  }