breakout/Score.js

22 lines
438 B
JavaScript

class Score {
constructor() {
this.reset();
}
reset() {
this.points = 0;
this.x = 235;
this.y = -10;
}
add(x) {
this.points += x;
}
update(ctx) {
if (this.y != 20) this.y++;
if (this.y > 0) {
ctx.font = "20px Consolas";
ctx.fillStyle = 'Black';
ctx.fillText('Score: ' + this.points, this.x, this.y);
}
}
}