Workshop › Rhythm Lanes › Step 26 of 35
Every ten hits in a row raise the score multiplier by one, up to four. Late in a long streak every note matters four times as much, and one miss costs the multiplier too.
```js
const multiplier = () => Math.min(4, 1 + Math.floor(combo / 10))
score += 300 * multiplier()
score += 100 * multiplier()
ctx.textAlign = 'right'
ctx.fillText('Combo ' + combo + ' x' + multiplier(), canvas.width - 12, 24)
```Math.floor(combo / 10) is how many full tens the combo has (Math.floor rounds down); plus 1 it is the multiplier.Math.min(4, ...) takes the smaller number, so it never goes above 4.multiplier() at the moment of the hit, after the combo grew.textAlign = 'right' puts the text's right end at x, 12 pixels from the right edge.noteY, after an empty line, write multiplier.press, multiply the two scores by multiplier().draw, under the Score line, write the two combo lines.Skills: Game states
← Hits in a row The song ends →