- Home /
Question by
pstephan1187 · Jun 13, 2012 at 09:10 AM ·
javascriptarraysobjectsmap
How to Manually write a 2 dimensional array in javascript
I am making a tower defense game that is based on a hex grid map. The map is being generate via a script that I have written. It currently generates a map with random elements on it. What I want to do is feed the script a pre-written 2d array that I have already defined. How do I write a 2d array in javascript? I want something similar to:
var map : String[2,2] = new array(
array(new tileObject('blah blah'), new tileObject('blah blah')),
array(new tileObject('blah blah'), new tileObject('blah blah'))
);
Then I would like to reference the tileObjects via something like map[1,2].buildTurret('blaster') or something similar.
Would anyone be able to give me a little direction on that. Thanks!
Comment