Skip to content

Instantly share code, notes, and snippets.

@nefarioustim
Forked from andyhd/world.js
Created April 18, 2012 08:59
Show Gist options
  • Save nefarioustim/2412180 to your computer and use it in GitHub Desktop.
Save nefarioustim/2412180 to your computer and use it in GitHub Desktop.
render with one loop
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