From 6fcccc7ed1d69b5bc7a64acaf3d8995739938e14 Mon Sep 17 00:00:00 2001 From: sbrl Date: Wed, 8 Jun 2016 13:52:55 +0100 Subject: [PATCH] Add multiple hill sets. --- HillSet.js | 2 +- renderer.js | 20 ++++++++++++++++---- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/HillSet.js b/HillSet.js index 88b42c3..900bf33 100644 --- a/HillSet.js +++ b/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"; diff --git a/renderer.js b/renderer.js index 9fdb105..d1bd0ca 100644 --- a/renderer.js +++ b/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); + } } /**