Draw sprite for high score limit
This commit is contained in:
parent
5a93448d9b
commit
25c25f1d67
14
src/scene.js
14
src/scene.js
|
@ -177,6 +177,17 @@ class Scene extends Screen {
|
||||||
this.context.lineTo(this.width(), height);
|
this.context.lineTo(this.width(), height);
|
||||||
this.context.stroke();
|
this.context.stroke();
|
||||||
|
|
||||||
|
this.context.save();
|
||||||
|
this.context.translate(0, height);
|
||||||
|
|
||||||
|
let pattern = this.context.createPattern(Scene.highscore, 'repeat');
|
||||||
|
this.context.fillStyle = pattern;
|
||||||
|
this.context.beginPath();
|
||||||
|
this.context.rect(0, 0, this.width(), 32);
|
||||||
|
this.context.fill();
|
||||||
|
|
||||||
|
this.context.restore();
|
||||||
|
|
||||||
this.context.font = "15px Arial";
|
this.context.font = "15px Arial";
|
||||||
this.context.fillStyle = "rgb(255, 255, 255)";
|
this.context.fillStyle = "rgb(255, 255, 255)";
|
||||||
this.context.fillText("High score: " + Math.floor(100 * this.currentMaxHeight), 0, height - 5);
|
this.context.fillText("High score: " + Math.floor(100 * this.currentMaxHeight), 0, height - 5);
|
||||||
|
@ -298,3 +309,6 @@ class Scene extends Screen {
|
||||||
|
|
||||||
Scene.background = new Image();
|
Scene.background = new Image();
|
||||||
Scene.background.src = "img/background.png";
|
Scene.background.src = "img/background.png";
|
||||||
|
|
||||||
|
Scene.highscore = new Image();
|
||||||
|
Scene.highscore.src = "img/highscore.png";
|
||||||
|
|
Loading…
Reference in New Issue