You might want to try this just to confirm what happens when you have a clear and obvious input:
function fillMap() {
var map = [[0]];
That should give you the output of: [4, -5]
Some potential issues
- map isn't defined anywhere
- length isn't defined anywhere
- xTrans is not defined anywhere
- zTrans is not defined anywhere
It seems unlikely, based on what I see, that the if condition can be met:
xTrans >= tmp[0]-1 && xTrans < tmp[0] // translates to if xTrans == tmp[0] - 1
Some other thoughts
- You're better off using
bounds.push
instead ofbounds[length] = $val
for(var y=0; y<map.length ;y++) { for(var x=0; x<map[0].length ;x++) {
would be safer/faster asvar yLen = map.length; var xLen = map[0].length; for(var y=0; y<yLen ;y++) { for(var x=0; x<xLen ;x++) {
bounds[length] = -y - 4 * y
is the same asbounds[length] = -5 * y;