Draw sprite for high score limit

This commit is contained in:
Thomas Forgione 2018-08-22 16:01:12 +02:00
parent 5a93448d9b
commit 25c25f1d67
No known key found for this signature in database
GPG Key ID: 203DAEA747F48F41
1 changed files with 14 additions and 0 deletions

View File

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