Text Game Review [Archive] - C Board

PDA

View Full Version : Text Game Review


punkrockguy318
10-21-2003, 06:55 PM
Hey.. I made a charecter generator for a RPG. I'm not done yet, but I want someone to review my code. How can I improve it? Is there something that could ahve been done ebtter? I'm a begginer in C++, I just want opinions. I've attatched the ZIP with the Headers, sources, and vc6 workspace. Thanks!

Dark Nemesis
10-21-2003, 07:40 PM
Looks good, however:
cout << "What class do you choose to be(E/M)? ";
(F/M)*, and maybe use numbers instead?

A few things you might want to add: More classes (Thief, Assassin, Ranger, Archer, Soldier, Farmer), more races (Abandonned Angel, Dragon-Men, Dwarf), Male/Female, perks! (If you haven't played fallout ask me, and I will describe), Name (don't recall...).

Coding looks fine to me, might want to keep a standart indent, not 3, 4, etc... (I sugest 2, I always use 2, it's the easiest and less time-consuming).

Next-time you post code for review, maybe add it all into one file so it's easier to look at.

major_small
10-21-2003, 07:56 PM
looks good from what i saw... on the Dark Nemesis' note, you should include a 'main.cpp' file so we know where to start, and mayve a txt file with a brief explanation of what each file does... or comments in the main.cpp file...

adding to what Dark Nemesis said, I would do this differently:

...
// Get players race
cout << endl
<< "Elf" << endl
<< "Orc" << endl
<< "Human" << endl
<< endl << endl;

cout << "What race do you choose?(E/O/H) ";
cin >> cvalue;
...this is how i would do it (cvalue is an int) ...
// Get players race
cout << endl << "Choose your race\n"
<< " 1. Elf" << endl
<< " 2. Orc" << endl
<< " 3. Human" << endl
<< "Enter the number of your choice: ";
cin >> cvalue;
...or ...
// Get players race
cout << endl
<< "[E]lf" << endl
<< "[O]rc" << endl
<< "[H]uman" << endl
<< endl << endl;

cout << "What race do you choose?(E/O/H) ";
cin >> cvalue;
...

punkrockguy318
10-22-2003, 05:18 AM
Thanks a lot guys. I noticed another problem though. Let's say you type in "Elf" for the first question. It will put 'l' and 'f' in the queue and it will answer the questions for you. how can i only get the first charecter?

ps: how can i clear screen?

major_small
10-22-2003, 05:59 AM
try this:...
cin>>cvalue;
cin.ignore(1000,'\n');
...
the 1000 is a semi-random value...

Dark Nemesis
10-22-2003, 06:42 AM
ps: how can i clear screen?
clrscr();

major_small
10-22-2003, 07:59 AM
some compilers don't have that in the library tho... if yours doesn't just usesystem("cls");it's in the cstdlib library...

or you can just check the FAQ (http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1031963460&id=1043284385) (i suggest option 5 ;))

punkrockguy318
10-22-2003, 01:26 PM
wow, thanks everyone! everything you said works great! Just one more problem. Its the same one as with the cin, but with the cin.getline. If you put cin.ignore, you have to push return again to continue. That's kindof annoying. Is there a way I can avoid that?

punkrockguy318
10-22-2003, 01:38 PM
Also, i heard you should make your header file names match your source files. Why can't I just make a mob.h for the mob struct and other mob variables?

Dark Nemesis
10-23-2003, 07:08 AM
Originally posted by punkrockguy318
wow, thanks everyone! everything you said works great! Just one more problem. Its the same one as with the cin, but with the cin.getline. If you put cin.ignore, you have to push return again to continue. That's kindof annoying. Is there a way I can avoid that?
Why do you want to use cin.ignore if it does that?

punkrockguy318
10-23-2003, 02:31 PM
Originally posted by Dark Nemesis
Why do you want to use cin.ignore if it does that?
then what else can i use?

confuted
10-23-2003, 02:54 PM
Originally posted by punkrockguy318
Also, i heard you should make your header file names match your source files. Why can't I just make a mob.h for the mob struct and other mob variables?
You can

Dark Nemesis
10-23-2003, 03:00 PM
Originally posted by punkrockguy318
then what else can i use?
I don't know what cin.ignore does, my question was why do you use it if it gives you problems, someone might know an alternative.

punkrockguy318
10-23-2003, 03:47 PM
oh, i gotya

Dark Nemesis
10-23-2003, 06:35 PM
...How can someone tell you an alternative if you don't tell us what it is for. So you didn't get me...

Stan100
10-25-2003, 07:01 PM
I know you're not done yet, so don't be angry at me, you just haven't mentioned it yet.

If it's a generated, shouldn't the character's stats be exported to a file?

What would it be used for? I can't think of a text rpg (on the computer), that would be able to use it? Maybe a D&D session, but besides that, what?

punkrockguy318
10-26-2003, 07:39 AM
Originally posted by Stan100
I know you're not done yet, so don't be angry at me, you just haven't mentioned it yet.

If it's a generated, shouldn't the character's stats be exported to a file?

What would it be used for? I can't think of a text rpg (on the computer), that would be able to use it? Maybe a D&D session, but besides that, what?

Yeah, it'll be exported to a file. I'll make a seperate function for that later; I'm not familiar with file functions. I know a little. fopen() fwrite() fread(), but I'll have to review it again.

It's going to be used for a text RPG. There are a lot of stats that aren't in there yet that need to be; but I will add them as I need them. EXP, Weapons, Magic, Inventory, Level, Current position on map. I've recently added the battle engine; so I needed to add the EXP, weapons, magic, and level. I still have a lot of work to do. I'll show you what I have once I get it a little cleaned up; its pretty messy and uncommented right now. Thanks again for all your help!