I'm trying to make a small game similar to minesweeper or battleship and I need to use some kind of 10x10 grid. To store information for this grid I was planning to use a 10x10 2d array. My problem so far is that I can't figure out how to access, check, and change the contents of the individual locations of the array. My questions is this. How, or what is the best way to create an array or something else to store the series of integers I need and later access them as necessary?
I've tried some different ways to do this, with my last attempt being:
var row1 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
var row2 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
var row3 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
var row4 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
var row5 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
var row6 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
var row7 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
var row8 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
var row9 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
var row10= [0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
var coords = [row1, row2, row3, row4, row5, row6, row7, row8, row9, row10];
I intended to have 0 signify an unclicked space, 1 signify a clicked space that didn't contain anything, and 2 signify a space that contained an object.
coords[x][y]