Highscores on a webpage?

Hi, I'm writing a game that you just leave open and every 5 minutes your score will increase, how can I make it so when someone quits the application, their highscore will be displayed on a webpage that everyone can view?


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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#include <cstdlib>
#include <iostream>
#include <windows.h>
#include <conio2.h>

using namespace std;

int main()
{
    int a = 1;
    int copper = 0;
    int diamond = 0;
    int score = 0;
    
    int b = 0;;
    int c = 0;
    
    
    gotoxy(26,5);
    cout << "| Welcome to Extreme Mining! |" << endl;
    gotoxy(25,6);
    cout << "| You gain 1 ore every minute! |" << endl;
    gotoxy(18,7);
    cout << "| When you get 5 of an ore, you auto-sell them. |" << endl;
    gotoxy(25,25);
    system("PAUSE");
    clrscr();
    
    while(a == 1)
    {
        
                gotoxy(1, 3);
        cout << "Copper: " << copper;
        gotoxy(1, 4);
        cout << "Diamond: " << diamond;
        gotoxy(1, 5);
        cout << "Score: " << score;
                
        gotoxy(1,1);
        cout << "Mining Progress: [      ]\n";
        Sleep(10000);
        system("CLS");
        
                gotoxy(1, 3);
        cout << "Copper: " << copper;
        gotoxy(1, 4);
        cout << "Diamond: " << diamond;
        gotoxy(1, 5);
        cout << "Score: " << score;
        
        gotoxy(1,1);
        cout << "Mining Progress: [|     ]\n";
        Sleep(10000);
        system("CLS");
        
                gotoxy(1, 3);
        cout << "Copper: " << copper;
        gotoxy(1, 4);
        cout << "Diamond: " << diamond;
        gotoxy(1, 5);
        cout << "Score: " << score;
                
        gotoxy(1,1);
        cout << "Mining Progress: [||    ]\n";
        Sleep(10000);
        system("CLS");
        
                gotoxy(1, 3);
        cout << "Copper: " << copper;
        gotoxy(1, 4);
        cout << "Diamond: " << diamond;
        gotoxy(1, 5);
        cout << "Score: " << score;
                
        gotoxy(1,1);
        cout << "Mining Progress: [|||   ]\n";
        Sleep(10000);
        system("CLS");
        
                gotoxy(1, 3);
        cout << "Copper: " << copper;
        gotoxy(1, 4);
        cout << "Diamond: " << diamond;
        gotoxy(1, 5);
        cout << "Score: " << score;
        
        gotoxy(1,1);
        cout << "Mining Progress: [||||  ]\n";
        Sleep(10000);
        system("CLS");
        
                gotoxy(1, 3);
        cout << "Copper: " << copper;
        gotoxy(1, 4);
        cout << "Diamond: " << diamond;
        gotoxy(1, 5);
        cout << "Score: " << score;
                
        gotoxy(1,1);
        cout << "Mining Progress: [||||| ]\n";
        Sleep(10000);
        system("CLS");
        
                gotoxy(1, 3);
        cout << "Copper: " << copper;
        gotoxy(1, 4);
        cout << "Diamond: " << diamond;
        gotoxy(1, 5);
        cout << "Score: " << score;
        
        gotoxy(1,1);
        cout << "Mining Progress: [||||||]\n";
        
        b = rand()%100+1;
        
        if(b >= 1 && b <= 10)
        {
            diamond++;
        }
        else if(b >= 11)
        {
            copper++;
        }
        
        if(copper == 5)
        {
            score = score +5;
            copper = 0;
        }
        else if(diamond == 5)
        {
            score = score +50;
            diamond = 0;
        }
        
        
        if(score == 100)
        {
            textcolor(LIGHTMAGENTA);
        }
        
    }
    
    
    
    
    gotoxy(25,25);
    system("PAUSE");
    return 0;
            
}
Last edited on
You need to have a webserver.
You could use a class constructor and deconstructor to manipulate a scores before exiting.(deconstructors execute when a class object is about to be destroyed, meaning when exiting the program.)
closed account (S6k9GNh0)
1) Why use Conio?
2) Why include windows.h?
3) Why are you clearing the screen? Why use system("pause")?
4) You need to learn how to make an HTTP request and maybe learn how to manage a remote database.
Last edited on
Look into NodeJS ... that should help ...
a good site for that should be gamefromscratch.com
Topic archived. No new replies allowed.