aboutsummaryrefslogtreecommitdiff
path: root/particle.js
diff options
context:
space:
mode:
Diffstat (limited to 'particle.js')
-rw-r--r--particle.js8
1 files changed, 8 insertions, 0 deletions
diff --git a/particle.js b/particle.js
index bfafa87..fc7d249 100644
--- a/particle.js
+++ b/particle.js
@@ -49,4 +49,12 @@ function Particle(x, y, m, c) {
dist(x1, y1, x2, y2)
) < 2;
}
+
+ this.collide = function(otherp) {
+ var dist = function(x1, y1, x2, y2) {
+ return Math.sqrt(Math.pow(x1 - x2, 2) + Math.pow(y1 - y2, 2));
+ };
+
+ return dist(this.pos.x, this.pos.y, otherp.pos.x, otherp.pos.y) < this.mass + otherp.mass;
+ }
}