Add multiple hill sets.

This commit is contained in:
Starbeamrainbowlabs 2016-06-08 13:52:55 +01:00
parent e760f74ffd
commit 6fcccc7ed1
2 changed files with 17 additions and 5 deletions

View File

@ -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";

View File

@ -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);
}
}
/**