Bugfix: jarring jumps when resetting the scenery

This commit is contained in:
Starbeamrainbowlabs 2016-06-08 13:41:02 +01:00
parent e7750c891c
commit e760f74ffd

View file

@ -25,7 +25,7 @@ class HillSet
{ {
this.controlPoints = []; 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( this.controlPoints.push(new Vector(
x + (i !== 0 ? random(25) : 0), x + (i !== 0 ? random(25) : 0),
@ -34,10 +34,10 @@ class HillSet
} }
// Make everything as seamless as possible // 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 = 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 // TODO: Add a few points before this to make th smooth line join up upon reset correctly
var prevPoints = []; var prevPoints = [];
for(let point of this.controlPoints) for(let point of this.controlPoints)