class Lives { constructor() { this.reset(); } reset() { this.lives = 3; this.y = 10; } lost() { this.lives--; return this.lives==0; } get() { return this.lives; } update(ctx) { if (this.y != 48) this.y++; if (this.y > 0) { let txt = (String.fromCharCode(parseInt('26A1', 16))+" ").repeat(this.lives); ctx.font = "18px Consolas"; ctx.fillStyle = 'Green'; this.x = ctx.canvas.width - ctx.measureText(txt).width; ctx.fillText(txt, this.x, this.y); } } }