I'm trying to make my own tile-based game; a really simple one. I decided to put necessary level data into a JSON file to be read by my primitive attempt at a game engine..
{
"tileset":"main.png",
"layers":[
[
[8 ,8 ,8 ,8 ,8 ,8 ,8 ,8 ,8 ,8 ,8 ],
[0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ],
[0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ],
[0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ],
[0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ],
[0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ],
[0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ],
[3 ,3 ,3 ,3 ,2 ,0 ,0 ,0 ,0 ,0 ,0 ],
[1 ,1 ,1 ,1 ,5 ,0 ,0 ,0 ,0 ,0 ,0 ]
], [
[1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ],
[0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ],
[0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ],
[0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ],
[0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ],
[0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ],
[0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ],
[1 ,1 ,1 ,1 ,1 ,0 ,0 ,0 ,0 ,0 ,0 ],
[1 ,1 ,1 ,1 ,1 ,0 ,0 ,0 ,0 ,0 ,0 ]
]
]
}
However, I'm a complete newbie to JavaScript and the like, and even jQuery is a tad bit to wrap my head around. How would I read this file and then place each of the layer's jagged arrays into their own variables?
e.g. Take the first layer array and put it into, say, var first_layer
and so on and so forth