public class MinesweeperGame extends Game{
private static final int SIDE = 9;
private int countMinesOnField;
private GameObject[][] gameField = new GameObject[SIDE][SIDE];
@Override
public void initialize(){
setScreenSize(SIDE,SIDE);
createGame();
}
private void createGame(){
for (int x = 0; x < gameField.length; x++) {
for (int y = 0; y < gameField[x].length; y++) {
gameField[y][x] = new GameObject(x,y);
int mine = (getRandomNumber(10)==0);
if (mine == 1) {
isMine = true;
countMinesOnField+=1;
}
else{
isMine = false;
setCellColor(y, x, Color.ORANGE);
}
}
countMineNeighbors();
}
}
public class GameObject {
public int x;
public int y;
public boolean isMine;
GameObject (int x, int y, boolean isMine) {
this.x = x;
this.y = y;
this.isMine = isMine;
}
}
package com.javarush.games.minesweeper;
import com.javarush.engine.cell.*;
public class MinesweeperGame extends Game{
private static final int SIDE = 9;
private int countMinesOnField;
private GameObject[][] gameField = new GameObject[SIDE][SIDE];
@Override
public void initialize(){
setScreenSize(SIDE,SIDE);
createGame();
}
private void createGame(){
for (int x = 0; x < gameField.length; x++) {
for (int y = 0; y < gameField[x].length; y++) {
gameField[y][x] = new GameObject(x,y);
int mine = (getRandomNumber(10)==0);
if (mine == 1) {
isMine = true;
countMinesOnField+=1;
}
else{
isMine = false;
setCellColor(y, x, Color.ORANGE);
}
}
countMineNeighbors();
}
}
}