From e760f74ffd064bafbf56df07b06a5a27f359f6f3 Mon Sep 17 00:00:00 2001 From: sbrl Date: Wed, 8 Jun 2016 13:41:02 +0100 Subject: [PATCH] Bugfix: jarring jumps when resetting the scenery --- HillSet.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/HillSet.js b/HillSet.js index ccdacfd..88b42c3 100644 --- a/HillSet.js +++ b/HillSet.js @@ -25,7 +25,7 @@ class HillSet { this.controlPoints = []; - for (let x = 0, i = 0; x < this.size.x; x += this.controlPointInterval, i++) + for (let x = 0, i = 0; x <= this.size.x; x += this.controlPointInterval, i++) { this.controlPoints.push(new Vector( x + (i !== 0 ? random(25) : 0), @@ -34,10 +34,10 @@ class HillSet } // Make everything as seamless as possible - this.controlPoints[this.controlPoints.length - 2].x = this.size.x - this.controlPoints[2].x; - this.controlPoints[this.controlPoints.length - 2].y = this.size.y; this.hillLine = new SmoothLine(); + this.hillLine.add(this.controlPoints[this.controlPoints.length - 3].clone().subtract(new Vector(this.size.x * 2, 0))); + this.hillLine.add(this.controlPoints[this.controlPoints.length - 2].clone().subtract(new Vector(this.size.x * 2, 0))); // TODO: Add a few points before this to make th smooth line join up upon reset correctly var prevPoints = []; for(let point of this.controlPoints)