Bounce is now better

This commit is contained in:
2021-11-13 00:34:29 +01:00
parent 135f7d8a41
commit ae92c56957
6 changed files with 174 additions and 49 deletions

28
Lives.js Normal file
View File

@ -0,0 +1,28 @@
class Lives {
constructor(ctx) {
this.ctx = ctx;
this.reset();
this.ctx.font = "30px Consolas";
let m = ctx.measureText('Score: 00000');
this.x = ctx.canvas.width - m.width;
this.y = 20;
}
reset() {
this.lives = 3;
}
lost() {
this.lives--;
return this.lives==0;
}
update() {
if (this.y != 60) this.y++;
if (this.y > 0) {
let txt = (String.fromCharCode(parseInt('26A1', 16))+" ").repeat(this.lives);
this.ctx.font = "30px Consolas";
this.ctx.fillStyle = 'Green';
this.ctx.fillText(txt, this.x, this.y);
}
}
}