Creating an array & outputting its code definition for preloading

Posted by user422318 on Stack Overflow See other posts from Stack Overflow or by user422318
Published on 2012-04-09T16:59:08Z Indexed on 2012/04/09 17:28 UTC
Read the original article Hit count: 243

Filed under:
|
|

I want to create a 2d array that represents my 2d canvas. For each pixel, I will look up the value and then save an integer {0, 1, 2, 3, 4} as each element of the array. Unfortunately, this takes way too friggin' long to run each time I load the game.

How can I write a script that creates this array for me and outputs the array code so I can just paste it in a js file and have it preloaded? (I'm prototyping a game, so I just need to run this for my test map or two.)

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about arrays