My pokemon Console Game (Looking for Tips)

Hey guys, I spent a couple hours programming this game. I thought it would be fun to have a console type pokemon game. I ran into a problem on how to structure the code. I am wondering if each individual pokemon should have a class or whatnot...If you can, please take some time and copy paste my game into your ide and give me tips on how to structure the game. The game replicates the first battle of a pokemon blue/red gameboy game. Hope you will like what i have made. And I really would like to hear your tips on how to structure this game...If you can also please provide me information on how to structure a game..such as class structure. Thank you for your time :)

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
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
// PokemonApp.cpp
// Frank Novello

#include <iostream>
#include <string>
#include <windows.h>
#include <time.h>

using namespace std;


class Pokemon{
public:
    string name;
    int hp ;
    int lvl;
    
private:
};
class FirePokemon:public Pokemon{
    
};
class WaterPokemon:public Pokemon{
    
};
class GrassPokemon:public Pokemon{
    
};


Pokemon* myPokemon = new Pokemon;
Pokemon* compPokemon = new Pokemon;

FirePokemon* charmander = new FirePokemon;
WaterPokemon* squirtle = new WaterPokemon;
GrassPokemon* bulbasaur = new GrassPokemon;

FirePokemon* ccharmander = new FirePokemon;
WaterPokemon* csquirtle = new WaterPokemon;
GrassPokemon* cbulbasaur = new GrassPokemon;

void startGame();
void userPokemon();
void computersPokemon();
void firstbattle(Pokemon* , Pokemon*);
void battleMenu();
void userAttack();
void compAttack();
void image();
string name;

int main()
{
	bool quit = false;
	char choice;
	startGame();
    
	while (!quit)
	{
		userPokemon();
		computersPokemon();
		firstbattle(myPokemon, compPokemon);
		cout << "Would you like to play again?(y/n)" << endl;
		cin >> choice;
		if (choice == 'y')
		{
			quit = false;
		}else
		{
			quit = true;
		}
	}
	
	system("PAUSE>nul");
	return 0;
}

void startGame()
{
	image();
	cout << "Press 'Space' to continue.." << endl;
	system("PAUSE>nul");
	while (GetAsyncKeyState(VK_SPACE==0)){} // wait for player to press space to continute
	system("cls");
	cout << "Professor Oak: Hello there! Welcome to the world of POKeMON!My name is Oak!\n"
    "People call me the POKeMON PROF! This world is inhabited by creatures called \nPOKeMON!"
    "For some people, POKeMON are pets. Others use them for fights.Myself... I study POKeMON as a profession.\n"
    "First, what is your name?" << endl;
	cin >> name;
	system("cls");
	bool bmenu = true;
	char playerChoice = ' ';
	while (bmenu == true)
	{
		int pokeChoice;
		cout << "Hi, " << name <<"! Choose your pokemon" << endl;
		cout << "1: Charmander " << endl;
		cout << "2: Squirtle   " << endl;
		cout << "3: Bulbasaur  " << endl;
		cin >> pokeChoice;
		system("cls");
		switch (pokeChoice)
		{
            case 1:
                myPokemon = charmander;
                break;
            case 2:
                myPokemon = squirtle;
                break;
            case 3:
                myPokemon = bulbasaur;
                break;
            default:
                cout << "Incorrect Selection! ";
                break;
		}
		myPokemon->lvl = 1;
		if (pokeChoice ==1)
		{
			myPokemon->name = "Charmander";
			myPokemon->hp = 50;
		}
		else if (pokeChoice ==2 )
		{
			myPokemon->name = "Squirtle";
			myPokemon->hp	= 60;
		}else
		{
			myPokemon->name = "Bublasaur";
			myPokemon->hp = 40;
		}
        
		cout << "These are your pokemon stats: " << endl;
		cout << "Name: " <<myPokemon->name << endl;
		cout << "HP:   " <<myPokemon->hp << endl;
		cout << "lvl:  " <<myPokemon->lvl << endl;
        
		cout << "Do you wish to keep this pokemon?(y/n)\n" << endl;
		cin >>playerChoice;
		system("cls");
		if (playerChoice == 'y')
		{
			bmenu = false;
			break;
		}else
		{
			bmenu = true;
			continue;
		}
	}
    
	cout << "Congrats on your first pokemon " << name << "! " << "You selected " << myPokemon->name << "\n";
	
	cout << "Press 'Space' to continue.." << endl;
	system("PAUSE>nul");
	while (GetAsyncKeyState(VK_SPACE==0)){} // wait for player to press space to continute
}
void userPokemon()
{
	if (myPokemon == charmander)
	{
		myPokemon->hp = 50;
	}
	if (myPokemon == squirtle)
	{
		myPokemon->hp = 60;
	}
	if (myPokemon == bulbasaur)
	{
		myPokemon->hp = 40;
	}
}
void computersPokemon(){
	system("cls");
	cout << "This is your first battle. Against " ;
	if (myPokemon == charmander)
	{
		compPokemon = csquirtle;
		compPokemon->name = "Squirtle";
		compPokemon->lvl = 1;
		compPokemon->hp = 60;
	}
	else if (myPokemon == squirtle || myPokemon == bulbasaur)
	{
		compPokemon = ccharmander;
		compPokemon->name = "Charmander";
		compPokemon->lvl = 1;
		compPokemon->hp = 50;
	}
	cout << compPokemon->name << endl;
	cout << "Press 'Space' to continue.." << endl;
	cout << endl;
	system("PAUSE>nul");
	
	while (GetAsyncKeyState(VK_SPACE==0)){} // wait for player to press space to continute
}

void firstbattle(Pokemon* user, Pokemon* comp)
{
	system("cls");
	cout <<"Name: " << comp->name << endl;
	cout <<"Lvl:  " << comp->lvl  << endl;
	cout <<"HP:   " << comp->hp   << endl;
	cout << endl;
    
	cout << "Name: " << user->name << endl;
	cout << "Lvl:  " << user->lvl  << endl;
	cout << "HP:   " << user->hp   << endl;
    
	cout << endl;
	bool battle = true;
	while (true)
	{
		if (myPokemon->hp <= 0 || compPokemon->hp <= 0)
		{
			battle = false;
			break;
		}
		battleMenu();
		compAttack();
	}
	if (myPokemon->hp < 0)
	{
		cout << myPokemon->name << " has fainted! You are out of pokemon" << endl;
	}else
        cout << "\nNice job " << name << "! You just won your first poke Battle!";
}

void battleMenu(){
	int x;
	
	cout << "1: FIGHT"<< "   " << "2: PkMn" << endl;
	cout << "3: ITEMS"<< "   " << "4: RUN " << endl;
	cin >> x;
	system("cls");
    
	cout <<"Name: " << compPokemon->name << endl;
	cout <<"Lvl:  " << compPokemon->lvl  << endl;
	cout <<"HP:   " << compPokemon->hp   << endl;
	cout << endl;
    
	cout << "Name: " << myPokemon->name << endl;
	cout << "Lvl:  " << myPokemon->lvl  << endl;
	cout << "HP:   " << myPokemon->hp   << endl << endl;
    
	switch (x)
	{
        case 1:
            userAttack();
            break;
        case 2:
            break;
        case 3:
            break;
        case 4:
            break;
        default:
            break;
	}
    
	
}
void userAttack(){
	
	int x;
	if (myPokemon == charmander)
	{
		//charmander moves
		cout << "1: Scratch"<< endl;
		cout << "2: Growl  "<< endl;
	}
	if (myPokemon == squirtle)
	{
		//squirtle moves
		cout << "1: Tackle   " << endl;
		cout << "2: Tail Whip" << endl;
	}
	if (myPokemon == bulbasaur)
	{
		//bulbasaur moves
		cout << "1: Tackle " << endl;
		cout << "2: Growl  " << endl;
	}
	cin >> x;
	switch (x)
	{
        case 1:
            compPokemon->hp -=35;
            break;
        case 2:
            break;
        default:
            cout << "Wrong selection" ;
            break;
	}
	system("CLS");
	cout <<"Name: " << compPokemon->name << endl;
	cout <<"Lvl:  " << compPokemon->lvl  << endl;
	cout <<"HP:   " << compPokemon->hp   << endl;
	cout << endl;
    
	cout << "Name: " << myPokemon->name << endl;
	cout << "Lvl:  " << myPokemon->lvl  << endl;
	cout << "HP:   " << myPokemon->hp   << endl;
}
void compAttack(){
	int x;
	if (compPokemon == charmander)
	{
		//charmander moves
		cout << "1: Scratch"<< endl;
		cout << "2: Growl  "<< endl;
	}
	if (compPokemon == squirtle)
	{
		//squirtle moves
		cout << "1: Tackle   " << endl;
		cout << "2: Tail Whip" << endl;
	}
	if (compPokemon == bulbasaur)
	{
		//bulbasaur moves
		cout << "1: Tackle " << endl;
		cout << "2: Growl  " << endl;
	}
	srand(time(0));
	x = rand() % 3 +1;
	
	switch (x)
	{
        case 1:
            myPokemon->hp -=35;
            break;
        case 2:
            myPokemon->hp -=35;
            break;
        case 3:
            break;
        default:
            cout << "Wrong selection" ;
            break;
	}
	system("CLS");
	cout <<"Name: " << compPokemon->name << endl;
	cout <<"Lvl:  " << compPokemon->lvl  << endl;
	cout <<"HP:   " << compPokemon->hp   << endl;
	cout << endl;
    
	cout << "Name: " << myPokemon->name << endl;
	cout << "Lvl:  " << myPokemon->lvl  << endl;
	cout << "HP:   " << myPokemon->hp   << endl;
}
Last edited on
add this function...i ran out of space
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
void image ()
{
	cout <<	"                                                                                " << endl;
	cout <<	"                                                                                " << endl;
	cout <<	"                                          ~+                                    " << endl;
	cout <<	"                                        ,.+=.I                                  " << endl;
	cout <<	"              ?=~,==        I:,.??.=   .~,.~?  ====...:                         " << endl;
	cout <<	"         ?,.=~++++?+=.,    .+?+=.:?+:~,.=++=.:?.++?:++.     .=~:.~I?            " << endl;
	cout <<	"         .=?++++?===++=?  ~~,+++?+++:~?+..~+=..=++++++:, ?+~,~+++..++=.I        " << endl;
	cout <<	"        ~~.:+++++~..:+++~....+++++=..+++?++....?++++++=.~+++?.+++:.+++.         " << endl;
	cout <<	"         ~~~~.++++++?~.?+,+++.~++++?.~++++++++.~++++~+,++.?+++.+++?++.          " << endl;
	cout <<	"          ~I~~.+++++..?++...+~.+..++++~.......~++~.~.?~++???+~++++++.+          " << endl;
	cout <<	"            ~~,++++~~.~++++++.?+.~,..?++~.~~~..~+.~..+.~?++?~~+~++++.           " << endl;
	cout <<	"             ?~..+++:~:.~+~.,.+?.+~~~~~... ?~~~~=~~~.+++.~~~.++.+++.            " << endl;
	cout <<	"              ~~~+++.~~~~~~~~~~~     =~~+          ~~~~~+? ~~~~.++~~            " << endl;
	cout <<	"              I~~...~? I?I  =??         ?             ?=I  ?==~~~.. ..:.        " << endl;
	cout <<	"               ?~~~~+                                         +~=~              " << endl;
	cout <<	"                                                                                " << endl;
	cout <<	"                                                                                " << endl;
	cout <<	"                                                                                " << endl;
	cout <<	"                                                                                " << endl;
	cout <<	"                                                                                " << endl;
	cout <<	"                                                                                " << endl;
	cout <<	"                                                  .~~+=                         " << endl;
	cout <<	"                                                ?    I=+                        " << endl;
	cout <<	"                                                ,=I:,.:~:                       " << endl;
	cout <<	"                                                ...+?  ?.                       " << endl;
	cout <<	"                                                  ~=. =                         " << endl;
	cout <<	"                                         .~~.   .~ =+++.+                       " << endl;
	cout <<	"                                  ~++++  .I.   .  .~~~??.                       " << endl;
	cout <<	"                                 .+?.?? ...~~:++..~=...~~                       " << endl;
	cout <<	"                                  +?~~~.         .  . .. +                      " << endl;
	cout <<	"                               +==:~,.,=          .~~~~~  ,~+                   " << endl;
	cout <<	"                          ~:I :~:~:?==~?+I        ~~. ~~. :?                    " << endl;
	cout <<	"                         = I~I=:.~==,+,.         .+~  ~=~                       " << endl;
	cout <<	"                         I~~???,:~:~+=~:,        .~   .=.                       " << endl;
	cout <<	"                             .~ ~+ .            ,.~=  :...                      " << endl;
	cout <<	"        ~. +        ?       ~                                                   " << endl;
	cout <<	"       .I..   ~  ~    ? .?     =.I+ .. .. ,I.?.  . =..~. . .. , .?...  .        " << endl;
	cout <<	"                                                                                 "<< endl;
	
}
This is my recommendation:

Just have a "Pokemon" class, that has a constructor taking the name, type (enum) and then the base stats for that Pokemon, as well as its level. From there, you can implement different Pokemon all from the same class! Here is an example:
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
// Stat struct for simplifying passing data

class Pokemon {
    public:
        enum Types {
            TYPE_NORMAL,
            TYPE_FIRE,
            // etc
        };

        struct Stats {
            int hp;
            int atk;
            int def;
            int special;
            int speed;
        };

        Pokemon(std::string name, Types type1, Types type2, Stats base, int level)
            : _name(name), _type1(type1), // etc
        {
            this->_stats.hp = // work out stats from level and base
            // etc
        }

    private:
        std::string _name;
        Types _type1, _type2;
        Stats _stats;
        // etc
};
Hey, thanks for the reply! I really like your class structure. Do you know of any resources that I can read up on for creating class structures and such ?

And thanks again I really like your layout!
Topic archived. No new replies allowed.