-
-
Save nefarioustim/2412180 to your computer and use it in GitHub Desktop.
render with one loop
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function drawMap(map) { | |
var x, y, | |
width = map[0].length, | |
current_node = map.length * width; | |
while (current_node--) { | |
x = current_node % width; | |
y = ~~(current_node / width); | |
drawTile({ | |
x: x, | |
y: y | |
}, { | |
top: map[y-1][x-1], | |
right: map[y-1][x], | |
bottom: map[y][x], | |
left: map[y][x-1] | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment