From 703faca4f0d6811d2775bfb8866a83b2ab46787f Mon Sep 17 00:00:00 2001 From: SebastianCrow Date: Thu, 5 Mar 2015 00:28:58 +0100 Subject: [PATCH] Fixed entity MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It’s possible to define fixed, non-draggable entity --- js/verlet-1.0.0.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/js/verlet-1.0.0.js b/js/verlet-1.0.0.js index bdf342e..531ab01 100644 --- a/js/verlet-1.0.0.js +++ b/js/verlet-1.0.0.js @@ -507,7 +507,7 @@ function VerletJS(width, height, canvas) { this.canvas.onmousedown = function(e) { _this.mouseDown = true; var nearest = _this.nearestEntity(); - if (nearest) { + if (nearest && (nearest.a ? !nearest.a.fixed : !nearest.fixed)) { _this.draggedEntity = nearest; } }; @@ -626,7 +626,7 @@ VerletJS.prototype.draw = function() { // highlight nearest / dragged entity var nearest = this.draggedEntity || this.nearestEntity(); - if (nearest) { + if (nearest && (nearest.a ? !nearest.a.fixed : !nearest.fixed)) { // highlight only dynamic entities this.ctx.beginPath(); this.ctx.arc(nearest.pos.x, nearest.pos.y, 8, 0, 2*Math.PI); this.ctx.strokeStyle = this.highlightColor;