Created
April 15, 2012 23:42
-
-
Save sessa/2395363 to your computer and use it in GitHub Desktop.
Row by Row collision box layer based upon window inner height/size.
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 windowCollisionBox() { | |
var width = window.innerWidth; | |
var height = window.innerHeight; | |
var grid = []; | |
rowNum = 0; | |
while(rowNum <= height) { | |
if(!rowNum || rowNum == height){ // First and Last Row | |
colNum = 0; | |
row = []; | |
while(colNum <= width) { | |
row.push(1); | |
colNum++; | |
} | |
} else { | |
row = []; | |
colNum = 0; | |
while(colNum <= width) { | |
if(!colNum || colNum == width) { // First & Last Column | |
row.push(1) | |
} else { | |
row.push(0); | |
} | |
colNum++; | |
} | |
} | |
grid.push(row); | |
rowNum++; | |
} | |
return grid; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment