I have a tile object declared as follows:
var tile = {
x: 0,
y: 0,
w: canvas.width / numoftiles,
h: canvas.width / numoftiles,
color: "#FFFFFF"
};
I have a multidimensional array to store a number of these tile objects, which I declare like so:
var tiles = [[]];
I loop through the length of my canvas adding these tiles to fill the screen like so:
for (i = 0; i < (canvas.height / numoftiles); i++) {
for (j = 0; j < (canvas.width / numoftiles); j++) {
tiles[i][j] = new tile();
}
}
My error occurs on the line:
tiles[i][j] = new tile();
The JavaScript console returns "Uncaught TypeError: tile is not a constructor"
How can I insert tile objects to a specific location in my multidimensional array?