Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //This generates the mines
- public void makeMSMine() {
- int i = 0, coordX, coordY;
- for (; i < mscountMine;) {
- coordX = (int) (Math.random() * msFieldNumber);
- coordY = (int) (Math.random() * msFieldNumber);
- if (map[coordX][coordY] == msEmptyField) {
- map[coordX][coordY] = msMINE;
- i++;
- }
- }
- }
- @Override
- public void actionPerformed(ActionEvent e) {
- Object localObject = e.getSource();
- int xCoord, yCoord;
- String[] tmp_str = ((JButton) localObject).getName().split("_");
- xCoord = Integer.parseInt(tmp_str[0]);
- yCoord = Integer.parseInt(tmp_str[1]);
- if (map[xCoord][yCoord] == msMINE) { //game over when you click on where the mine is randomly generated
- showMessage("Game Over", userNameInput + ", you stepped on a mine~~~");
- flag = true;
- showMSMine();
- return;
- }
- dfs(xCoord, yCoord, 0);
- checkSuccess();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement