aboutsummaryrefslogtreecommitdiff
path: root/scores.c
diff options
context:
space:
mode:
Diffstat (limited to 'scores.c')
-rw-r--r--scores.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/scores.c b/scores.c
index f840692..11a983f 100644
--- a/scores.c
+++ b/scores.c
@@ -126,3 +126,25 @@ char *get_score_at(int pos, int *score)
*score = scores[pos].score;
return scores[pos].initials;
}
+
+int is_high_score(int score)
+{
+ return (score > scores[9].score);
+}
+
+void add_high_score(const char *initials, int score)
+{
+int i,j;
+
+ for(i=0;i<10;i++) {
+ if(score > scores[i].score) {
+ for(j=8;j>=i;j--) {
+ scores[j+1].score = scores[j].score;
+ memcpy(scores[j+1].initials, scores[j].initials, 3);
+ }
+ scores[i].score = score;
+ memcpy(scores[i].initials, initials, 3);
+ break;
+ }
+ }
+}