class GameOver { constructor() { this.w = 240; this.h = 120; this.cx = 360 / 2; this.cy = 640 / 2; this.x = this.cx - this.w/2; this.y = this.cy - this.h/2; } update(ctx) { ctx.fillStyle = "rgba(0, 0, 0, 0.5)"; ctx.fillRect(this.x, this.y, this.w, this.h); this.centerText(ctx, 'GAME OVER', this.cy, '48px', 'Consolas', 'Black'); this.centerText(ctx, '(Press "N" to start)', this.cy + 48, '24px', 'Consolas', 'Black'); } centerText(ctx, txt, y, s, f, c) { ctx.font = s + ' ' + f; ctx.fillStyle = 'Black'; let x = (ctx.canvas.width - ctx.measureText(txt).width) / 2; ctx.fillText(txt, x, y); } }