p5winter/score.js

19 lines
286 B
JavaScript
Raw Permalink Normal View History

2024-01-05 14:48:28 +00:00
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;
}
}