Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. //This generates the mines
  2. public void makeMSMine() {
  3. int i = 0, coordX, coordY;
  4. for (; i < mscountMine;) {
  5. coordX = (int) (Math.random() * msFieldNumber);
  6. coordY = (int) (Math.random() * msFieldNumber);
  7. if (map[coordX][coordY] == msEmptyField) {
  8. map[coordX][coordY] = msMINE;
  9. i++;
  10. }
  11. }
  12. }
  13.  
  14.  
  15. @Override
  16. public void actionPerformed(ActionEvent e) {
  17.  
  18. Object localObject = e.getSource();
  19. int xCoord, yCoord;
  20. String[] tmp_str = ((JButton) localObject).getName().split("_");
  21. xCoord = Integer.parseInt(tmp_str[0]);
  22. yCoord = Integer.parseInt(tmp_str[1]);
  23.  
  24. if (map[xCoord][yCoord] == msMINE) { //game over when you click on where the mine is randomly generated
  25. showMessage("Game Over", userNameInput + ", you stepped on a mine~~~");
  26. flag = true;
  27. showMSMine();
  28. return;
  29.  
  30. }
  31. dfs(xCoord, yCoord, 0);
  32. checkSuccess();
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement