Bounce is now better
This commit is contained in:
16
GameOver.js
Normal file
16
GameOver.js
Normal file
@ -0,0 +1,16 @@
|
||||
class GameOver {
|
||||
constructor(ctx) {
|
||||
this.ctx = ctx;
|
||||
this.x = ctx.canvas.width;
|
||||
this.y = ctx.canvas.height / 2 - 48;
|
||||
}
|
||||
update() {
|
||||
this.centerText('GAME OVER', this.y, '48px', 'Consolas', 'Black');
|
||||
}
|
||||
centerText(txt, y, s, f, c) {
|
||||
this.ctx.font = s + ' ' + f;
|
||||
this.ctx.fillStyle = 'Black';
|
||||
let x = (this.ctx.canvas.width - this.ctx.measureText(txt).width) / 2;
|
||||
this.ctx.fillText(txt, x, y);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user