Browse Source

Add multiple hill sets.

master
Starbeamrainbowlabs 5 years ago
parent
commit
6fcccc7ed1
  1. 2
      HillSet.js
  2. 20
      renderer.js

2
HillSet.js

@ -4,7 +4,7 @@ class HillSet
{
constructor(inSize, inHeightRange, inColour)
{
if(typeof inSize != "object") inSize = new Vector(2048, 500);
if(typeof inSize != "object") inSize = new Vector(2048, 1024);
if(typeof inHeightRange != "number") inHeightRange = 0.4;
if(typeof inColour != "string") inColour = "green";

20
renderer.js

@ -14,8 +14,14 @@ class Renderer
setup()
{
this.hillSet = new HillSet();
console.log(this.hillSet.toString());
this.hillSets = [];
this.hillSets.push(new HillSet(new Vector(2048, this.canvas.height * 0.9), 0.4, "rgb(102, 164, 90)"));
this.hillSets.push(new HillSet(new Vector(2048, this.canvas.height * 0.6), 0.4, "rgb(43, 131, 35)"));
this.hillSets.push(new HillSet(new Vector(2048, this.canvas.height * 0.2), 0.4, "rgb(50, 111, 8)"));
this.hillSets[0].pos = new Vector(0, this.canvas.height - this.hillSets[0].size.y);
this.hillSets[1].pos = new Vector(0, this.canvas.height - this.hillSets[1].size.y);
this.hillSets[2].pos = new Vector(0, this.canvas.height - this.hillSets[2].size.y);
console.log(this.hillSets);
}
start()
@ -41,7 +47,10 @@ class Renderer
*/
update(dt)
{
this.hillSet.update(dt);
for(let hillSet of this.hillSets)
{
hillSet.update(dt);
}
}
render(canvas, context)
@ -50,7 +59,10 @@ class Renderer
/*context.fillStyle = "red";
context.fillRect(10, 10, 100, 100);*/
this.hillSet.render(this.context);
for(let hillSet of this.hillSets)
{
hillSet.render(context);
}
}
/**

Loading…
Cancel
Save