PDA

View Full Version : Most Effective Way To Load A TileMap


Ciubhran
05-01-2009, 12:45 PM
By tilemap I mean the standard map structure of tile based game.

1 1 0 1
1 0 0 1
0 0 1 1
0 1 1 1

That kind of thing.

I want to make a big map, but if I am going to hardcode an array like this, it's gonna make Flash CS4 lag like **** every time I try to change the page.

In C/C++ I just used to make a small file with 0's and 1's, then load them into an array one by one.

How would I go about doing this, efficiently, in AS3?

evride
05-01-2009, 02:24 PM
You can still hardcode it into an array and it will run faster than loading something in and saving it to an array. But if CS4 keeps crashing because maybe your computer is old and you barely met the min specs for it, then I would suggest using FlashDevelop and programming an FLA's class files outside of flash.

bluemagica
05-01-2009, 03:49 PM
You are not going to play in CS4 but in FP9 or 10, so you should worry about those! Anyway, i didn't quite understand your problem their.....hard coding the array shouldn't be the problem, cause you can have it during compilation so it won't lag!

If you are thinking of dynamically reading it from a file, then yes that will be a problem, however, you can just use a timer, and two counter variables, to load it slowly and show a preloader thingy infront.

Similarly for ingame use, you are not going to use the entire array at once, so use counter variables to keep track of which portion you want to use!(this is the logic used to make scrolling tile-based maps, which minimizes the memory load)!