Dinosaur battle game

I made something like this and posted for help a while ago, but that code was sloppy so i re-wrote it all and now i have a problem. I put in a random number generator that generates a number between 0 and 4, when it does that its supposed to make the opponent choose a move using switch statements but its not working it just outputs the random number generated. Its kind of like a pokemon battle system. I get no compiler errors it just doesnt work the way i want it to, run it and you'll see what i mean if you need to.

here is the entire code:

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
152
153
#include <iostream>
#include <string>
#include <ctime>
#include <random>

using namespace std;

void MAINPROGRAM();
void DinosaurRandomize();
void TRex();
void Player();

int PlayerHealth = 100;
int TRexHealth = 100;

bool turn = true;

int main()
{
    string choice;

    cout << "Hi, and welcome to the arena, here you will fight beasts" << endl;
    cout << "from the past. When your ready type 'Go'" << endl;
    cin >> choice;

    if(choice == "Go" || choice == "go")
    {
        MAINPROGRAM();
    }
}


void MAINPROGRAM()
{
    Player();
}

void Player()
{
    int Shotgun = 5;
    int Knife = 3;
    int Fist = 1;
    int RocketLauncher = 7;

    string choice;

    cout << "Your opponent is a T-Rex!" << endl;
    cout << "What will you do?" << endl;
    cout << "Only type the number of the move" << endl;
    cout << "\n";

        cout << "1. Use Shotgun - 5 DMG" << endl;
        cout << "2. Use Knife - 3 DMG" << endl;
        cout << "3. Use Fist - 1 DMG" << endl;
        cout << "4. Use Rocket Launcher - 7 DMG" << endl;
        cin >> choice;

    if(choice == "1." || choice == "1")
    {
        cout << "You used the Shotgun!" << endl;
        TRexHealth -= 5;
        cin.get();
        TRex();
    }
    else if(choice == "2." || choice == "2")
    {
        cout << "You used the Knife!" << endl;
        TRexHealth -= 3;
        cin.get();
        TRex();
    }
    else if(choice == "3." || choice == "3")
    {
        cout << "You used your fist!" << endl;
        TRexHealth -= 1;
        TRex();
    }
    else if(choice == "4." || choice == "4")
    {
        cout << "You used the Rocket Launcher" << endl;
        TRexHealth -= 7;
        TRex();
    }
}


void DinosaurRandomize() //Unused At the moment
{
    time_t T;
    time(&T);
    srand(T);

    for(int R = 0; R < 1; ++R)
    {
        cout << rand() % 2 << endl;
    }
}


void TRex()
{
    time_t T;
    time(&T);
    srand(T);

    for(int R = 0; R < 1; ++R)
    {
        cout << rand() % 5 << endl;
    }

    int Bite = 5;
    int Stomp = 4;
    int Charge = 5;
    int Chew = 7;

    while(true)
    {
        switch(T)
        {
            case 0:
                cout << "T-Rex used Bite!" << endl;
                PlayerHealth -= 5;
                turn == false;
                break;
            case 1:
                cout << "T-Rex used Stomp!" << endl;
                PlayerHealth -= 4;
                turn == false;
                break;
            case 2:
                cout << "T-Rex used Charge!" << endl;
                PlayerHealth -= 5;
                turn == false;
                break;
            case 3:
                cout << "T-Rex used Chew!" << endl;
                PlayerHealth -= 7;
                turn == false;
                break;
            case 4:
                cout << "T-Rex's attack missed!" << endl;
                PlayerHealth -= 0;
                turn == false;
                break;
        }

        if(turn == false)
        {
            Player();
        }
    }
}
You're not storing the randomized value in anything... you're just calling rand(), applying a modulo, and printing it. You don't have a variable that's holding on to its value. :|

-Albatross
How would i do that? sorry, its my first time working with rand and srand.
Last edited on
You just need some variable, like an int to store what rand() % 5 gives you back.

srand() (which should only be called once, by the way) sets up the random number generator, while rand() gives you back a random number every time you call it. The % puts a limit on the range of random numbers.

Good luck!

-Albatross
Last edited on
so what would i do? like

int x;
srand(x);

??
Um... no, the way you were calling srand() the first time was fine, it's just that you only needed to do it once in your whole program.

What you need to change is the way you're using the rand() % 5. Right now, you're printing the value it returns. Wouldn't you rather use = to store in in a variable so you can get it back later?*

*You actually don't really need a variable, but it makes things simpler.

-Albatross
oh so something like

rand() % 5 = x

?? i dont know like i said i have never worked with rand before.

Or no it would be

x = rand() % 5 right??
Last edited on
ok i got it working but i have another problem. I use a move, then the opponent uses a move, then the game ends? its suppoosed to keep going back and forth? why isnt it doing that?

New code:

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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
#include <iostream>
#include <string>
#include <ctime>
#include <random>

using namespace std;

void MAINPROGRAM();
void DinosaurRandomize();
void TRex();
void Player();

int PlayerHealth = 100;
int TRexHealth = 100;

bool turn = true;

int main()
{
    string choice;

    cout << "Hi, and welcome to the arena, here you will fight beasts" << endl;
    cout << "from the past. When your ready type 'Go'" << endl;
    cin >> choice;

    if(choice == "Go" || choice == "go")
    {
        MAINPROGRAM();
    }
}


void MAINPROGRAM()
{
    Player();
}

void Player()
{
    int Shotgun = 5;
    int Knife = 3;
    int Fist = 1;
    int RocketLauncher = 7;

    string choice;

    cout << "Your opponent is a T-Rex!" << endl;
    cout << "What will you do?" << endl;
    cout << "Only type the number of the move" << endl;
    cout << "\n";

        cout << "1. Use Shotgun - 5 DMG" << endl;
        cout << "2. Use Knife - 3 DMG" << endl;
        cout << "3. Use Fist - 1 DMG" << endl;
        cout << "4. Use Rocket Launcher - 7 DMG" << endl;
        cin >> choice;

    while(turn != false)
    {
        if(choice == "1." || choice == "1")
        {
            cout << "\n";
            cout << "You used the Shotgun!" << endl;
            cout << "\n";
            TRexHealth -= 5;
            turn == false;
            TRex();
        }
        else if(choice == "2." || choice == "2")
        {
            cout << "\n";
            cout << "You used the Knife!" << endl;
            cout << "\n";
            TRexHealth -= 3;
            turn == false;
            TRex();
        }
        else if(choice == "3." || choice == "3")
        {
            cout << "\n";
            cout << "You used your fist!" << endl;
            cout << "\n";
            TRexHealth -= 1;
            turn == false;
            TRex();
        }
        else if(choice == "4." || choice == "4")
        {
            cout << "\n";
            cout << "You used the Rocket Launcher" << endl;
            cout << "\n";
            TRexHealth -= 7;
            turn == false;
            TRex();
        }
    }
}


void DinosaurRandomize() //Unused At the moment
{
    time_t T;
    time(&T);
    srand(T);

    for(int R = 0; R < 1; ++R)
    {
        cout << rand() % 2 << endl;
    }
}


void TRex()
{
    int X;

    time_t T;
    time(&T);
    srand(T);

    for(int R = 0; R < 1; ++R)
    {
        X = rand() % 5;
    }

    int Bite = 5;
    int Stomp = 4;
    int Charge = 5;
    int Chew = 7;

    while(turn != false)
    {
        switch(X)
        {
            case 0:
                cout << "\n";
                cout << "T-Rex used Bite!" << endl;
                cout << "\n";
                PlayerHealth -= 5;
                turn == false;
                break;
            case 1:
                cout << "\n";
                cout << "T-Rex used Stomp!" << endl;
                cout << "\n";
                PlayerHealth -= 4;
                turn == false;
                break;
            case 2:
                cout << "\n";
                cout << "T-Rex used Charge!" << endl;
                cout << "\n";
                PlayerHealth -= 5;
                turn == false;
                break;
            case 3:
                cout << "\n";
                cout << "T-Rex used Chew!" << endl;
                cout << "\n";
                PlayerHealth -= 7;
                turn == false;
                break;
            case 4:
                cout << "\n";
                cout << "T-Rex's attack missed!" << endl;
                cout << "\n";
                PlayerHealth -= 0;
                turn == false;
                break;
        }

        if(turn = false)
        {
            Player();
        }
    }
}
You may want to check which equals you're using on lines 140, 147, 154, 161, 168, and 172.

-Albatross
Last edited on
Ah, i got it working now, thanks :D
Ok i have one more problem. When the health of the player or the opponent reach 0 i want it to display a message saying something but that never happens. It just keeps subtracting health? why is that?

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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
#include <iostream>
#include <string>
#include <ctime>
#include <random>
#include <windows.h>

using namespace std;

void MAINPROGRAM();
void DinosaurRandomize();
void TRex();
void Player();
void Entrance();

int PlayerHealth = 100;
int TRexHealth = 100;

bool turn = true;

int main()
{
    Entrance();
}

void Entrance()
{
    string choice;

    cout << "Hi, and welcome to the arena, here you will fight beasts" << endl;
    cout << "from the past. When your ready type 'Go'" << endl;
    cin >> choice;

    if(choice == "Go" || choice == "go")
    {
        MAINPROGRAM();
    }
}

void MAINPROGRAM()
{
    Player();
}

void Player()
{
    int Shotgun = 5;
    int Knife = 3;
    int Fist = 1;
    int RocketLauncher = 7;

    string choice;

        cout << "1. Use Shotgun - 5 DMG" << endl;
        cout << "2. Use Knife - 3 DMG" << endl;
        cout << "3. Use Fist - 1 DMG" << endl;
        cout << "4. Use Rocket Launcher - 7 DMG" << endl;
        cin >> choice;

    while(turn != false)
    {
        if(choice == "1." || choice == "1")
        {
            cout << "\n";
            cout << "You used the Shotgun!" << endl;
            cout << "\n";
            TRexHealth -= 5;
            cout << "T-Rex's Health: " << TRexHealth << endl;
            turn == false;
            TRex();
        }
        else if(choice == "2." || choice == "2")
        {
            cout << "\n";
            cout << "You used the Knife!" << endl;
            cout << "\n";
            TRexHealth -= 3;
            cout << "T-Rex's Health: " << TRexHealth << endl;
            turn == false;
            TRex();
        }
        else if(choice == "3." || choice == "3")
        {
            cout << "\n";
            cout << "You used your fist!" << endl;
            cout << "\n";
            TRexHealth -= 1;
            cout << "T-Rex's Health: " << TRexHealth << endl;
            turn == false;
            TRex();
        }
        else if(choice == "4." || choice == "4")
        {
            cout << "\n";
            cout << "You used the Rocket Launcher" << endl;
            cout << "\n";
            TRexHealth -= 7;
            cout << "T-Rex's Health: " << TRexHealth << endl;
            turn == false;
            TRex();
        }
        else if(PlayerHealth <= 0)
        {
            cout << "You have lost! Press ENTER to go back to the entrance." << endl;
            cin.get();
            Entrance();
        }
        else if(TRexHealth <= 0)
        {
            cout << "You have defeated the T-Rex!!!" << endl;
            cin.get();
            Entrance();
        }
    }
}


void DinosaurRandomize() //Unused At the moment
{
    time_t T;
    time(&T);
    srand(T);

    for(int R = 0; R < 1; ++R)
    {
        cout << rand() % 2 << endl;
    }
}


void TRex()
{
    int X;

    time_t T;
    time(&T);
    srand(T);

    for(int R = 0; R < 1; ++R)
    {
        X = rand() % 5;
    }

    int Bite = 5;
    int Stomp = 4;
    int Charge = 5;
    int Chew = 7;

    while(turn != false)
    {
        switch(X)
        {
            case 0:
                cout << "\n";
                cout << "T-Rex used Bite!" << endl;
                cout << "\n";
                PlayerHealth -= 5;
                cout << "Your Health: " << PlayerHealth << endl;
                turn == false;
                Player();
                break;
            case 1:
                cout << "\n";
                cout << "T-Rex used Stomp!" << endl;
                cout << "\n";
                PlayerHealth -= 4;
                cout << PlayerHealth << endl;
                turn == false;
                Player();
                break;
            case 2:
                cout << "\n";
                cout << "T-Rex used Charge!" << endl;
                cout << "\n";
                PlayerHealth -= 5;
                cout << PlayerHealth << endl;
                turn == false;
                Player();
                break;
            case 3:
                cout << "\n";
                cout << "T-Rex used Chew!" << endl;
                cout << "\n";
                PlayerHealth -= 7;
                cout << PlayerHealth << endl;
                turn == false;
                Player();
                break;
            case 4:
                cout << "\n";
                cout << "T-Rex's attack missed!" << endl;
                cout << "\n";
                PlayerHealth -= 0;
                cout << PlayerHealth << endl;
                turn == false;
                Player();
                break;
        }
    }
}
Your "Else if playerhealth <= 0" should become a "if playerhealth <= 0".
Same for the TRexHealth.
Ok i changed it but it didnt fix the problem.
Inside player() you call TRex(), and TRex() calls player(). You just have loops within loops.

TRex() shouldn't have a loop in it, which means it doesn't need a "turn". Also make sure to not call player.

Then you get back to the original player(), but the loop doesn't ask for a choice again, so you need to move the start of the while up a little. (to line 50).

The loop in player can be while(true), only ending via break when health is too low.

But, when the game is over, you call Entrance, which is going to make another game inside the game you are playing. Rather, simply have those conditions break the loop so that the function ends.

Then you get back to entrance, and it is done with so the program ends. You could make a loop in entrance that only continues while choice is "Go". Make sure to cin >> choice from within the loop, otherwise it can't update.

Something that is hiding these errors is that Player and TRex health is a global variable. Consider having the health's within player() and then pass the player's health as a reference variable to TRex.

Last edited on
Ok now i have 2 dinosaurs so i made this in my player function

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
time_t T;
    time(&T);
    srand(T);

    int A;

    for(int R = 0; R < 3; ++R)
    {
        A = rand() % 2;
    }

    switch(A)
    {
        case 0:
            TRex();
            break;
        case 1:
            VRaptor();
            break;
    }

        if(A == 1)
        {
            opponentH == TRexHealth;
        }
        else if(A == 2)
        {
            opponentH == VRaptorHealth;
        }


this is supposed to choose an opponent and based on the opponent it chooses it will assign opponentH to the opponents health. but when i run it it keeps looping and screwing up, what am i doing wrong? Here is all my code.

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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
#include <iostream>
#include <string>
#include <ctime>
#include <random>

using namespace std;

void MAINPROGRAM();
void DinosaurRandomize();
void TRex();
void Player();
void Entrance();
void VRaptor();
void Hospital();

int PlayerHealth = 100;
int TRexHealth = 100;
int VRaptorHealth = 100;
int opponentH = 0;

bool turn = true;

int main()
{
    string choice;

    cout << "This is the arena, a place where you can fight ancient beasts" << endl;
    cout << "\n";
    cout << "When your ready type 'Ready'" << endl;
    cin >> choice;

        if(choice == "Ready" || choice == "ready")
        {
            Player();
        }
}

void Player()
{
    int Shotgun = 5;
    int Knife = 3;
    int Fist = 1;
    int RocketLauncher = 7;

    string choice;

    time_t T;
    time(&T);
    srand(T);

    int A;

    for(int R = 0; R < 3; ++R)
    {
        A = rand() % 2;
    }

    switch(A)
    {
        case 0:
            TRex();
            break;
        case 1:
            VRaptor();
            break;
    }

        if(A == 1)
        {
            opponentH == TRexHealth;
        }
        else if(A == 2)
        {
            opponentH == VRaptorHealth;
        }

        cout << "1. Use Shotgun - 5 DMG" << endl;
        cout << "2. Use Knife - 3 DMG" << endl;
        cout << "3. Use Fist - 1 DMG" << endl;
        cout << "4. Use Rocket Launcher - 7 DMG" << endl;
        cin >> choice;

    while(turn != false)
    {
        if(PlayerHealth <= 0)
        {
            cout << "You have lost! Press ENTER to go back to the entrance." << endl;
            turn = false;
            Hospital();
        }

        if(choice == "1." || choice == "1")
        {
            cout << "\n";
            cout << "You used the Shotgun!" << endl;
            cout << "\n";
            opponentH -= 5;
            cout << "T-Rex's Health: " << TRexHealth << endl;
            TRex();
        }
        else if(choice == "2." || choice == "2")
        {
            cout << "\n";
            cout << "You used the Knife!" << endl;
            cout << "\n";
            opponentH -= 3;
            cout << "T-Rex's Health: " << TRexHealth << endl;
            TRex();
        }
        else if(choice == "3." || choice == "3")
        {
            cout << "\n";
            cout << "You used your fist!" << endl;
            cout << "\n";
            opponentH -= 1;
            cout << "T-Rex's Health: " << TRexHealth << endl;
            TRex();
        }
        else if(choice == "4." || choice == "4")
        {
            cout << "\n";
            cout << "You used the Rocket Launcher" << endl;
            cout << "\n";
            opponentH -= 7;
            cout << "T-Rex's Health: " << TRexHealth << endl;
            TRex();
        }
    }
}


void DinosaurRandomize()
{
    time_t T;
    time(&T);
    srand(T);

    int A;

    for(int R = 0; R < 3; ++R)
    {
        A = rand() % 2;
    }

    switch(A)
    {
        case 0:
            TRex();
            break;
        case 1:
            VRaptor();
            break;
    }
}


void TRex()
{
    int X;

    time_t T;
    time(&T);
    srand(T);

    for(int R = 0; R < 1; ++R)
    {
        X = rand() % 5;
    }

    int Bite = 5;
    int Slash = 6;
    int Pounce = 4;
    int QuickAttack = 5;

    if(TRexHealth <= 0)
        {
            cout << "\n";
            cout << "You have defeated the T-Rex!!!" << endl;
            cout << "\n";
            cin.get();
        }

        switch(X)
        {
            case 0:
                cout << "\n";
                cout << "T-Rex used Bite!" << endl;
                cout << "\n";
                PlayerHealth -= 5;
                cout << "Your Health: " << PlayerHealth << endl;
                cout << "\n";
                Player();
                break;
            case 1:
                cout << "\n";
                cout << "T-Rex used Stomp!" << endl;
                cout << "\n";
                PlayerHealth -= 4;
                cout << "Your Health: " << PlayerHealth << endl;
                cout << "\n";
                Player();
                break;
            case 2:
                cout << "\n";
                cout << "T-Rex used Charge!" << endl;
                cout << "\n";
                PlayerHealth -= 5;
                cout << "Your Health: " << PlayerHealth << endl;
                cout << "\n";
                Player();
                break;
            case 3:
                cout << "\n";
                cout << "T-Rex used Chew!" << endl;
                cout << "\n";
                PlayerHealth -= 7;
                cout << "Your Health: " << PlayerHealth << endl;
                cout << "\n";
                Player();
                break;
            case 4:
                cout << "\n";
                cout << "T-Rex's attack missed!" << endl;
                cout << "\n";
                PlayerHealth -= 0;
                cout << "Your Health: " << PlayerHealth << endl;
                cout << "\n";
                Player();
                break;
    }
}


void VRaptor()
{
    int X;

    time_t T;
    time(&T);
    srand(T);

    for(int R = 0; R < 1; ++R)
    {
        X = rand() % 5;
    }

    int Bite = 5;
    int Stomp = 4;
    int Charge = 5;
    int Chew = 7;

    if(VRaptorHealth <= 0)
        {
            cout << "\n";
            cout << "You have defeated the Veloci Raptor!!!" << endl;
            cout << "\n";
            cin.get();
        }

        switch(X)
        {
            case 0:
                cout << "\n";
                cout << "Raptor used Bite!" << endl;
                cout << "\n";
                PlayerHealth -= 5;
                cout << "Your Health: " << PlayerHealth << endl;
                cout << "\n";
                Player();
                break;
            case 1:
                cout << "\n";
                cout << "Raptor used Stomp!" << endl;
                cout << "\n";
                PlayerHealth -= 4;
                cout << "Your Health: " << PlayerHealth << endl;
                cout << "\n";
                Player();
                break;
            case 2:
                cout << "\n";
                cout << "Raptor used Charge!" << endl;
                cout << "\n";
                PlayerHealth -= 5;
                cout << "Your Health: " << PlayerHealth << endl;
                cout << "\n";
                Player();
                break;
            case 3:
                cout << "\n";
                cout << "Raptor used Chew!" << endl;
                cout << "\n";
                PlayerHealth -= 7;
                cout << "Your Health: " << PlayerHealth << endl;
                cout << "\n";
                Player();
                break;
            case 4:
                cout << "\n";
                cout << "Raptor's attack missed!" << endl;
                cout << "\n";
                PlayerHealth -= 0;
                cout << "Your Health: " << PlayerHealth << endl;
                cout << "\n";
                Player();
                break;
    }
}

void Hospital()
{
    cout << "\n";
    cout << "Welcome to the hospital" << endl;
    cout << "\n";
}


1
2
3
4
5
6
7
8
9
10
11
12
void MAINPROGRAM();
void DinosaurRandomize();
void TRex();
void Player();
void Entrance();
void VRaptor();
void Hospital();

int PlayerHealth = 100;
int TRexHealth = 100;
int VRaptorHealth = 100;
int opponentH = 0;

make a class please.
I could do that but how will it help? (I never use classes)
its called object oriented programming, and making an object called dinosaur would allow you to create multiple dinosaurs without making a whole new set of variables for each one. just a new object.
It can make your job easier, you can create a "Basic" Dinosaur, and create all the other Dinosaurs based on the "Basic" one, without needing to rewrite most of the code.
Topic archived. No new replies allowed.