HOW TO MAKE HIGHSCORE FOR GAME

Jun 23, 2014 at 9:44pm
I need help. I made a game, something like Stick Run and now, only thing I need to make is highscore, but I don`t know how. I tried to find it but I did not. Pleas, could somebody tell me hot to create it :D :D :D
Jun 23, 2014 at 11:30pm
Really? I've played Stick Run and if you can make something like it then a high score should be trivial.
Jun 24, 2014 at 8:46am
I'd write it into a file like "score.data" and save it there, but I believe that isn't the fastest or secure way to do it. You can save it into registery but I don't know how to do that and if it is fast/secure or not.

You can look up these two things and use them, but if anyone knows better way to do it then these two ways I'd be glad to hear it.
Jun 24, 2014 at 4:20pm
For linux (locally), I have my game make a secret hidden file that is created at the end of the game. Then I read it and the public file in. If the public file doesn't match the hidden file, I use the hidden file to load the scores. I've never looked into hidden files on Windows so I can't advise on that.

http://prntscr.com/3w1j3t

This method makes it so your friends can't sneak and change the score on the public one and make it look like they beat you.

Now to do it online is a different story because unless they hack the game or use some cheating device, you shouldn't have to worry too much about the scores being inaccurate.
Last edited on Jun 24, 2014 at 4:21pm
Jun 24, 2014 at 11:09pm
for a highscore thing,


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <iostream.h>
#include <stdio.h>
using namespace std;
//(I think it's tedious to right std:: on everything, so I think using extra //memory is worth it)
//I'm a beginner, so this might not be good:

void highscore(int score, int highscore)
{
if (score > highscore)
highscore = score;

//then cout << highscore or something
return 0;


}



//If there's a list of highscores, then
void highscore (int score, int highscore[])
{
long int temp;
long int temp2;
//long int highscore[listsize];
//long int score;

if (score > highscore[0])
{
temp = highscore[i];
highscore[i] = score;
for (int i = 1; i < listsize; i++)
{
temp2 = highscore[i];
highscore[i] = temp;
temp = temp2;
}
}
}



//so in main, with a bool hitObstacle and a goto label named endofgame,
if (hitObstacle)
goto endofgame;
//end brackets for the loop to keep the game going;
}

endofgame:
highscore(score, highscore[])
/*hope this might work*/
Last edited on Jun 26, 2014 at 6:07pm
Jun 25, 2014 at 5:06am
That code won't compile. Lines 30 and 31 will tell you i isn't declared because you don't declare it until line 32. Problem with your code is that it can't handle usernames so the high scores are assumed to be the same player every time (ie no friend competition). You can either use two static arrays in parallel (ie if you only want the top 10 scores, make string username[10] and int score[10]) or two vectors in parallel to go over the top 10 scores. You could also use a map container if you wanted.

There are several ways to go about this depending on how you want the high score table to be set up.
Last edited on Jun 25, 2014 at 5:10am
Jun 26, 2014 at 6:06pm
Thanks. The code could then be:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include <iostream.h>
#include <stdio.h>
using namespace std;
//(I think it's tedious to right std:: on everything, so I think using extra //memory is worth it)
//I'm a beginner, so this might not be good:


void highscore(int score, int highscore)
{
if (score > highscore)
highscore = score;

//then cout << highscore or something
return 0;


}



//If there's a list of highscores, then
void highscore (int score, string scorename, int highscore[], string scorename[])
{
long int temp;
long int temp2;
string tempname;
string tempname2;
//long int highscore[listsize];
//long int score;
//string scorename;
//string highscorename[listsize];
if (score > highscore[0])
{
temp = highscore[0];
tempname = highscorename[0];
highscore[0] = score;
highscorename[0] = score;
for (int i = 0; i < listsize; i++)
{
temp2 = highscore[i];
tempname2 = highscorename[i];
highscore[i] = temp;
highscorename[i] = tempname;
temp = temp2;
tempname = tempname2;
}
}
}



//so in main, with a bool hitObstacle and a goto label named endofgame,
if (hitObstacle)
goto endofgame;
//end brackets for the loop to keep the game going;
}

endofgame:
highscore(score, highscore[])
/*hope this might work*/
Last edited on Jun 26, 2014 at 6:20pm
Jun 26, 2014 at 10:25pm
Thanks people :D
This all should help
Topic archived. No new replies allowed.