According to GameMaker2 arrays documentation, GML has 2d arrays. At the same time I could not find any references how can I create 2d array from code. I tried doing
board = array_create(global.MAX_HEIGHT);
for(var i = 0; i < global.MAX_HEIGHT; i++){
board[i] = array_create(global.MAX_WIDTH);
}
but that seems to have created a 1d array of 1d arrays, meaning I cannot access them using board[x, y]
(if I try it doesn't assign values properly) , or even board[x][y]
(compilation error). Is there a way to dynamically create 2d array? Or to access this array more elegantly, instead of having to use
inside_array = board[i];
inside_array[j] = value;