Text based game..

This is a discussion on Text based game.. within the C++ Programming forums, part of the General Programming Boards category; Hi,
I'm having some problems structuring my program. How to make it. I want to make a game where a ...

Text based game..

Hi,

I'm having some problems structuring my program. How to make it. I want to make a game where a player can select between 3 different types og character, select name and so on, and after that venture through the game. But, how can I make it? I think I'm going to make the 3 different character types in 3 different classes. If that's the best way of doing it?
If I should use that way, then how can I make it so only the class that the user selected is included?

I can't figure out if it's the best way og doing it? Maybe some of you already have found a solution to this problem and maybe have some tips, that would be useful for my consideration?

First I'd forget about writing code for a while and focus on developing the game in your head and putting down your thoughts on paper or your favorite text editor. Decide on whether you different players to have same capabilities(attributes and actions) or not? What capablities could they have? Who decides? Are there any overlapping capabilities (age, health, wealth, etc or speaking, walking, shooting, swordfighting, etc). If there are overlapping capabilities then using class inheritance may be to your advantage (if you know about it or are willing to learn as you go). Once you have all that data pretty well digested then starting to write pseudocode/code becomes easier.

hey im only a begginer proggramer in c++ but i have been trying at game design for 2 years or sometin like that and i got some advice:
class inheritance is a MUST
know 1 type of gui proggraming well, be it direct x/ openGL ext.
as he said, get your ideas down
dont start of with text based, get bigger. nobody wants text based anymore unless its online like a MUD.
if u want it to be online at least learn some basic network proggraming
read ANY tutorial you can on AI ( artificial intelligence ) like the 3 on this site
KNOW THESE CHAPTERS OF CPROGGRAMINGS TUTORIAL BY HEART:
loops ( repeat attack )
class inheritance ( to design you classes base like they all have health, defence ext.)
if statements ( if ( player health = 0 ) cout<< "you died"; )
the basics ( display in game messages with cout and manipulate strings easily with cin )
switch case ( useful to cut out long if statements, if you want to do like 10 or 15 if's)

Thx both
Well I can hear that I'm on the right track, but I'm still having the problem figuring out how I can include/use only the class for the specific character type.
I was thinking about at start having 4 classes, one for each character type, and one called player. Where player, has the current HP, MP, LEVEL, EXP stored. Is that a good way to do it?

Darkcode: Now the world is not just to make a game and get it out. You've have to learn and get better, especially if you want to live by it. I'm making a text based game because I want my programming skills to get better. Remember the sentence: You learn by doing.. If I had a break from C++, I wouldn't get better, would I But thx for the good advice.

preceding function works with all objects that are derived from character.

if some functions only works with a special character you can use typeid to check for its original type:
Character *p_character = new Orc(...);
if(typeid(*p_character) == typeid(Orc)) { // this should evaluate to true here

}

"unfortunately" typeid only works if the class has at least one virtual function.
and you might need to specify a special compiler option (e.g. /GR in vc)

well there you have some stuff to start with

note that i have not included member declarations - even though they would be there in the actual code

I only have one question about your beautiful example Raven Arkadon..
Where do you have the "("some_name", "some_clan");" from in line:
CharacterBase *p_character = new OrcCharacter("some_name", "some_clan");

the idea is to gather data from what the user wants his character to be
and then pass that data to the constructor of the desired character class.

in case there are many attributes for a character then the constructor would have to accept like 10 arguments - which looks pretty ugly - also youd have 10 variables.
that can be solved by using a struct which stores all data that is required to instanciate the character class

that way, the mage would get all the normal qualitys every class has, but also its own unique ones.MUCH easier than writing everything its own classes. ( by the way i used public on sorecrer because outside code will need to enter to affect the health amount and stats increase.)