19 lines
286 B
JavaScript
19 lines
286 B
JavaScript
|
export class ScoreManager {
|
||
|
constructor() {
|
||
|
this.score = 0;
|
||
|
this.combo = 0
|
||
|
}
|
||
|
|
||
|
addScore(toAdd) {
|
||
|
this.score += toAdd
|
||
|
}
|
||
|
|
||
|
onHit() {
|
||
|
this.combo += 1;
|
||
|
this.score += 200 * Math.min(1, (Math.min(this.combo, 16) /4))
|
||
|
}
|
||
|
|
||
|
resetCombo() {
|
||
|
this.combo = 0;
|
||
|
}
|
||
|
}
|