diff --git a/js/entities.js b/js/entities.js index 62a1173..a336a2b 100644 --- a/js/entities.js +++ b/js/entities.js @@ -25,6 +25,31 @@ function Block(lane, color, iter, distFromHex, settled) { this.distFromHex = 300; } + this.incrementOpacity = function() { + if (this.deleted) { + var lane = MainClock.sides - this.lane;// -this.position; + lane += MainClock.position; + + lane = (lane+MainClock.sides) % MainClock.sides; + + this.opacity = this.opacity - 0.1; + if (this.opacity <= 0) { + this.opacity = 0; + var i = 0; + var j = this.getIndex(); + this.parentArr.splice(j,1); + if (j < this.parentArr.length) { + for (i = j; i < this.parentArr.length; i++) { + this.parentArr[i].settled = 0; + } + } + } + } + if(!this.deleted && this.opacity < 1){ + this.opacity = this.opacity + 0.05; + } + }; + this.getIndex = function (){ for (var i = 0; i < this.parentArr.length; i++) { if (this.parentArr[i] == this) {