0

I have made scoreboards before in programs, but
i was wondering if there was an easier way, or at least a shorter way since this method will take up around 50 lines.

here's what I usually do

if (score_txt >= Score1)
{
   Score7.text = Score6.text;
   Score6.text = Score5.text;
   Score5.text = Score4.text;
   Score4.text = Score3.text;
   Score3.text = Score2.text;
   Score2.text = Score1.text;
   Score1.text = score_txt.text;
}
else if (score_txt >= Score2)
{
   Score7.text = Score6.text;
   Score6.text = Score5.text;
   Score5.text = Score4.text;
   Score4.text = Score3.text;
   Score3.text = Score2.text;
   Score2.text = score_txt.text;
}

and so on and so forth until all scores ar accounted for.
So, does anyone have any thoughts?

2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by Salem
0

Pseudo-code

# is score enough to make it onto the table anyway?
if ( score > table[last] ) {
  table[last] = score;  # drop the last place in favour of the new score
  sort( table );        # sort to find it's true place in the table
}
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.