I'm trying to figure out how to create a multidimensional array with fixed dimensions.
This stack overflow thread said a three dimensional array could be made like this:
var arrayName = new Array(new Array(new Array()));
and this tutorial said a single-dimensional array of fixed length could be created like this:
var varname = new Array(3);
I'm not sure how to make an multidimensional array of fixed size (I'm making one to create a hexagon grid). My guess is that you would have to do it something like this:
var hexgrid_radius = 20;
var array1 = new Array(hexgrid_radius);
for(int i = 0; i < array1.length; i++) {
var array2 = new Array(hexgrid_radius);
array1[i] = array2;
for(int j = 0; j < array2.length; j++) {
var array3 = new Array(hexgrid_radius);
array2[j] = array3;
}
}