Browse Source

Bugfix: jarring jumps when resetting the scenery

master
Starbeamrainbowlabs 5 years ago
parent
commit
e760f74ffd
  1. 6
      HillSet.js

6
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)

Loading…
Cancel
Save