Skip to content

Instantly share code, notes, and snippets.

@bogdancernat
Created November 13, 2013 22:58
Show Gist options
  • Save bogdancernat/7458045 to your computer and use it in GitHub Desktop.
Save bogdancernat/7458045 to your computer and use it in GitHub Desktop.
crash.js
function crash(x,y){
var n = []
n.push({x:x, y:y-1}); // top
n.push({x:x+1, y:y}); // right
n.push({x:x, y:y+1}); // bottom
n.push({x:x-1, y:y}); // left
n.push({x:x-1, y:y-1}); // corner left top
n.push({x:x+1, y:y-1}); // corner right top
n.push({x:x-1, y:y+1}); // corner left bottom
n.push({x:x+1, y:y+1}); // corner right bottom
for (var i = 0; i < n.length; i++) {
if(n[i].x >= 0 && n[i].x < 8
&& n[i].y >= 0 && n[i].y < 8){
if(matrix[n[i].x][n[i].y] == 'H'){
return true;
}
}
}
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment