Hello!
How do I create a custom 2D array that looks like the following code?
Checks the whole array for a random integer, according to that integer it places gem.
[CODE]my2DArray = [ R(), R(), R(), R(), R(), R() ],
[ R(), R(), R(), R(), R(), R() ],
[ R(), R(), R(), R(), R(), R() ],
[ R(), R(), R(), R(), R(), R() ],
[ R(), R(), R(), R(), R(), R() ],
[ R(), R(), R(), R(), R(), R() ]
for (var y = 0; y < 6; y++){
for (var x = 0; x < 6; x++) {
if (my2DArray[y][x] == 1) {
// place a gem here
}
}
}
function R() {
return Math.floor(Math.random() * (1 + 5 – 1)) + 1;
}
I have no idea how a class works, if someone could explain me how to make a custom class like “Gem” it would be awesome.
Thanks in Advance, AlmarM