Skip to content

score_animator

Anthony Samms edited this page Jun 2, 2026 · 1 revision

Produces an animated digit-roll effect that counts up to a target integer. Used by player to animate each result field (score, good, ok, bad, max combo, drumroll) in sequence.

ScoreAnimator

Construction

ScoreAnimator(int target);

Converts target to a string to determine digit count. Initialises a current_score_list of (digit, counter) pairs — one per digit — all starting at zero. digit_index begins at the last digit.

Members

Member Type Description
target_score string String representation of the target value
current_score_list vector<pair<int,int>> Per-digit (current_digit, counter) state
digit_index int Index of the digit currently being animated
is_finished bool True once all digits have reached their targets

next_score

std::string next_score();

Called once per animation step by player (update_score_animation). Each call either:

  • Increments the counter and cycles curr_digit by 1 (up to 9 increments per digit), or
  • Locks the digit to its target value and advances digit_index to the next (less significant → more significant order, right to left).

When all digits are locked (digit_index == -1), sets is_finished = true and returns the final value string.

The returned string is formatted to suppress leading zeros: while the animated value is zero and there are still digits being animated, a zero-padded string is returned; once the value becomes non-zero it is returned as a plain integer string.

player calls this at every 50 ms and plays the "num_up" sound when the returned value differs from the target for that field.

Clone this wiki locally