Nice function for "rolling score up"?
- by bobobobo
I'm adding to the player's score, and I'm using a per-frame formula like:
int score, displayedScore ;// score is ACTUAL score player has,
// displayedScore is what is shown this frame to the player
// (the creeping/"rolling" number)
float disparity = score - displayedScore ;
int d = disparity * .1f ; // add 1/10 of the difference,
if( !d ) d = signum( disparity ) ; // last 10 go by 1's
score += d ;
Where
inline int signum( float val ){
if( val > 0 ) return 1 ;
else if( val < 0 ) return -1 ;
else return 0 ;
}
So, it kind of works where it makes big changes rapidly, then it creeps in the last few one at a time.
But I'm looking for better (or possibly well known?) score-creeping functions. Any one?