Skip to content

Instantly share code, notes, and snippets.

@FredrikL FredrikL/gist:6580773
Last active Dec 23, 2015

Embed
What would you like to do?
Collision detection!?
for(var i= 0; i < entites.length; i++) {
if(py > (entites[i].y)) {
if(pw > entites[i].x &&
pw < (entites[i].x+10)){
player.x = entites[i].x -player.width;
} else if(player.x >= (entites[i].x+10) &&
player.x < (entites[i].x+20)) {
player.x = entites[i].x + 20;
}
} else {
if(Math.round(py) === Math.round(entites[i].y) &&
pw > entites[i].x &&
player.x < (entites[i].x + 20)) {
player.y = entites[i].y - player.height;
applyPlayerGravity = false;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.