# Dynamic maps

**URL:** <https://forum.kirupa.com/t/dynamic-maps/245246>\
**Category:** Uncategorized\
**Created:** [November 27, 2007, 9:05pm UTC](https://forum.kirupa.com/t/dynamic-maps/245246 "2007-11-27T21:05:07Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ArmoredSandwich](https://avatars.discourse-cdn.com/v4/letter/a/3e96dc/32.png) [@ArmoredSandwich](https://forum.kirupa.com/u/ArmoredSandwich)\
**Post date:** [November 27, 2007, 9:05pm UTC](https://forum.kirupa.com/t/dynamic-maps/245246/1 "2007-11-27T21:05:07Z")

</div>

okay, i have run into a problem i just cant find a solution for.

My game is tile based, so i have an array with in it other arrays representing the map.

Now i want another array, just like the map array, but then only 0’s. I want this because my a\* algorithm (I finally coded a working version! _oh happy day_ 😛 ) is based on 0’s and 1’s. The main array however is not just 0’s and 1’s but might go up to… well alot 😛

How would i do something like that, i have already tried:

```auto

_root.pathArray = mapArray;                
        for (i = 0; i < mapHeight; i ++)
            {
            for (j =0; j < mapWidth; j ++)
                {                        
                _root.pathArray*[j] = 0;
                }
            }    

```

And the same thing with concat. In both cases however if i change something in pathArray it also gets changed in the mapArray (reference?).

Just to clear up, i want an array such as below. In the same size but without any numbers but 0.

levelArray = [  
[1,1,1,1,1,1,1,1,1,1],  
[1,0,0,1,0,1,0,0,2,1],  
[1,0,0,1,0,1,1,0,0,1],  
[1,0,1,1,0,0,1,0,0,1],  
[1,0,0,1,0,0,0,0,1,1],  
[1,1,0,1,0,0,1,0,0,1],  
[1,0,0,1,0,0,0,0,0,1],  
[1,0,0,0,0,1,1,1,1,1],  
[1,0,0,0,0,0,0,0,0,1],  
[1,1,1,1,1,1,1,1,1,1]  
]

like this.

pathArray = [  
[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,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]  
];

any help pl0x? Greatly appreciated.
