Hi all, I’m attempting to make a minesweeper game. I’ve been given a template and am working off of that. Right now my problem is two things:
-
I need to write a function (I have it called drawMines), where it will accept two int array(column first, row numbers second) , and the number of entries in the array.
-
This is similar to the first but I need a function(I have it as drawNums) That accepts three characters(columns, rows and then characters to be drawn) as well as the number of entries in the arrays.
This is what I have so far, the grid is made and I just need those two functions but have no clue how to begin:
final int CELLSIZE = 50;
final int NUM_ROWS = 10;
final int NUM_COLS = 12;
void setup() {
size(600, 500); //size MUST be (NUM_COLS*CELLSIZE) by (NUM_ROWS*CELLSIZE);
noLoop(); //only draw once
}
void draw() {
drawGrid();
//create test arrays
int[] mineX = {3, 1, 8, 11, 8, 4}; //mine column numbers
int[] mineY = {4, 0, 7, 9, 2, 1}; //mine row numbers
drawMines(mineX, mineY, 6); //fill the cells with mines
int[] numX = {0, 10, 5, 2, 6, 7, 1, 11, 6};
int[] numY = {2, 3, 6, 8, 0, 9, 6, 1, 4};
char[] numValue = {'3', '1', '4', '2', '5', '6', '0', '7', '8'};
drawNums(numX, numY, numValue, 9);
}
//Draw Grid Function
void drawGrid(){
for (int i = 0; i < NUM_COLS; i++){
for (int j = 0; j < NUM_ROWS; j++){
int x = i*CELLSIZE;
int y = j*CELLSIZE;
noFill();
noStroke();
rect(x, y, CELLSIZE, CELLSIZE);
}
}
}
//Draw Mine Function
void drawMine(){
}
//Draw Numbers Function
void drawNums(){
}