Skip to content

Instantly share code, notes, and snippets.

@tpott
Created April 24, 2013 18:16
Show Gist options
  • Save tpott/5454257 to your computer and use it in GitHub Desktop.
Save tpott/5454257 to your computer and use it in GitHub Desktop.
server/objects/movable.js check for collisions
Movable.prototype.doICollide = function(collidables) {
var myPosition = this.position;
var myNewPos = this.position.clone().add(this.velocity);
// check if i collide with anything!
for (var id in collidables) {
if (collision(myPosition, myNewPos, collidables[id])) {
return true;
}
}
// i didn't collide!
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment