changed ball and bar for a sprite
This commit is contained in:
21
assets/js/Score.js
Normal file
21
assets/js/Score.js
Normal file
@ -0,0 +1,21 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user