[Tux4kids-commits] r125 - in tuxmath/trunk: docs src
David Bruce
dbruce-guest at alioth.debian.org
Thu Mar 8 23:04:08 CET 2007
Author: dbruce-guest
Date: 2007-03-08 22:04:08 +0000 (Thu, 08 Mar 2007)
New Revision: 125
Modified:
tuxmath/trunk/docs/changelog
tuxmath/trunk/src/highscore.c
tuxmath/trunk/src/titlescreen.c
Log:
high score work
Modified: tuxmath/trunk/docs/changelog
===================================================================
--- tuxmath/trunk/docs/changelog 2007-03-08 20:25:18 UTC (rev 124)
+++ tuxmath/trunk/docs/changelog 2007-03-08 22:04:08 UTC (rev 125)
@@ -1,5 +1,12 @@
changelog for "tuxmath"
+2007.Mar.08 (svn.debian.org/tux4kids - revision 125)
+ Game:
+ * High scores now saved to and read from file, not yet
+ visible to game player.
+ * svn repository move completed.
+ David Bruce <dbruce at tampabay.rr.com>
+
2007.Mar.05 (https://svn.tux4kids.net/tuxmath/ - revision 75)
Code:
* Most of tuxtype-derived code now using functions in
Modified: tuxmath/trunk/src/highscore.c
===================================================================
--- tuxmath/trunk/src/highscore.c 2007-03-08 20:25:18 UTC (rev 124)
+++ tuxmath/trunk/src/highscore.c 2007-03-08 22:04:08 UTC (rev 125)
@@ -9,6 +9,8 @@
* Copyright: See COPYING file that comes with this distribution
* (Briefly, GNU GPL version 2 or greater).
*/
+#include <string.h>
+
#include "highscore.h"
#include "tuxmath.h"
@@ -151,6 +153,9 @@
int read_high_scores_fp(FILE* fp)
{
char buf[PATH_MAX];
+ char* token;
+ const char delimiters[] = "\t";
+
char* name_read;
int score_read;
int diff_level;
@@ -180,6 +185,19 @@
}
/* Split up line with strtok()to get needed values, */
/* then call insert_score() for each line. */
+ token = strtok(buf, delimiters);
+ if (!token)
+ continue;
+ diff_level = atoi(token);
+
+ token = strtok(NULL, delimiters);
+ if (!token)
+ continue;
+ score_read = atoi(token);
+ /* Note that name can contain spaces - \t is only delimiter: */
+ name_read = strtok(NULL, delimiters);
+ /* Now insert entry: */
+ insert_score(name_read, diff_level, score_read);
}
return 1;
}
@@ -205,7 +223,7 @@
{
for (j = 0; j < HIGH_SCORES_SAVED; j++)
{
- fprintf(fp, "%d\t%d\t%s\n", i,
+ fprintf(fp, "%d\t%d\t%s\t\n", i,
high_scores[i][j].score,
high_scores[i][j].name);
}
Modified: tuxmath/trunk/src/titlescreen.c
===================================================================
--- tuxmath/trunk/src/titlescreen.c 2007-03-08 20:25:18 UTC (rev 124)
+++ tuxmath/trunk/src/titlescreen.c 2007-03-08 22:04:08 UTC (rev 125)
@@ -592,6 +592,16 @@
{
audioMusicUnload();
game();
+ /* See if player made high score list! */
+ if (check_score_place(ACE_HIGH_SCORE, Opts_LastScore()))
+ {
+ /* (Get name string from player) */
+ insert_score("Little Kindy", ACE_HIGH_SCORE, Opts_LastScore());
+ write_high_scores();
+#ifdef TUXMATH_DEBUG
+ print_high_scores(stderr);
+#endif
+ }
}
else
{
@@ -616,6 +626,17 @@
{
audioMusicUnload();
game();
+ /* See if player made high score list! */
+ if (check_score_place(ACE_HIGH_SCORE, Opts_LastScore()))
+ {
+ /* (Get name string from player) */
+ insert_score("Toothless Wonder", ACE_HIGH_SCORE, Opts_LastScore());
+ write_high_scores();
+#ifdef TUXMATH_DEBUG
+ print_high_scores(stderr);
+#endif
+ }
+
}
else
{
@@ -640,6 +661,16 @@
{
audioMusicUnload();
game();
+ /* See if player made high score list! */
+ if (check_score_place(ACE_HIGH_SCORE, Opts_LastScore()))
+ {
+ /* (Get name string from player) */
+ insert_score("Rock Climber", ACE_HIGH_SCORE, Opts_LastScore());
+ write_high_scores();
+#ifdef TUXMATH_DEBUG
+ print_high_scores(stderr);
+#endif
+ }
}
else
{
More information about the Tux4kids-commits
mailing list