コード例 #1
0
 private void exitActionPerformed(java.awt.event.ActionEvent evt) {
   if (size14.isSelected()) {
     Maze.gridSize = 14;
     Maze.afterChoose();
     this.dispose();
   } else if (size19.isSelected()) {
     Maze.gridSize = 19;
     Maze.afterChoose();
     this.dispose();
   } else if (size20.isSelected()) {
     Maze.gridSize = 20;
     Maze.afterChoose();
     this.dispose();
   } else if (size21.isSelected()) {
     Maze.gridSize = 21;
     Maze.afterChoose();
     this.dispose();
   } else if (size27.isSelected()) {
     Maze.gridSize = 27;
     Maze.afterChoose();
     this.dispose();
   } else if (size28.isSelected()) {
     Maze.gridSize = 28;
     Maze.afterChoose();
     this.dispose();
   } else if (size29.isSelected()) {
     Maze.gridSize = 29;
     Maze.afterChoose();
     this.dispose();
   } else if (size30.isSelected()) {
     Maze.gridSize = 30;
     Maze.afterChoose();
     this.dispose();
   }
 }
コード例 #2
0
ファイル: MazeManApplet.java プロジェクト: iuomo/java
  public void paint(Graphics g) {

    board.drawMaze();
    pacman.drawMazeMan(true);
    pacman.start();
  }
コード例 #3
0
ファイル: MazeApp.java プロジェクト: BogdanFloris/Maze
  public void actionPerformed(ActionEvent e) {
    if (e.getSource() == start2Button) {
      maze.sol = 2;
      timer1.start();
    }
    if (e.getSource() == resetButton) {
      timer1.stop();
      timer2.stop();
      timer3.stop();
      timer4.stop();
      maze.sol = 0;
      this.maze.readFromFile("maze.txt");
      maze.repaint();
    }
    if (e.getSource() == start1Button) {
      maze.sol = 1;
      timer2.start();
      // maze.leastVisitedNeighbour();
    }
    if (e.getSource() == start3Button) {
      maze.sol = 3;
      timer3.start();
    }
    if (e.getSource() == start4Button) {
      maze.sol = 4;
      maze.dijkstra();
      timer4.start();
    }
    if (maze.sol == 2) {
      if (!maze.cells[maze.currentX][maze.currentY].isEnd()) {
        maze.stepLeastVistedNeighbour();
        maze.repaint();
      } else {
        timer1.stop();
      }
    }

    if (maze.sol == 1) {
      if (!maze.cells[maze.currentX][maze.currentY].isEnd()) {
        maze.randomStep();
        maze.repaint();
      } else {
        timer2.stop();
      }
    }
    if (maze.sol == 3) {
      if (!maze.cells[maze.currentX][maze.currentY].isEnd()) {
        maze.stepRightHand();
        maze.repaint();
      } else {
        timer3.stop();
      }
    }
    if (maze.sol == 4) {
      if (!maze.cells[maze.currentX][maze.currentY].isEnd()) {
        maze.stepDjikstra();
        maze.repaint();
      } else {
        timer4.stop();
      }
    }
  }