Created
April 24, 2013 18:16
-
-
Save tpott/5454257 to your computer and use it in GitHub Desktop.
server/objects/movable.js check for collisions
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
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