Text RPG game question
Ok, I have fooled around with GLUT and some windows GDI but have decided to go back and start with a simple text based rpg game. I don't consider moving a square around the screen in glut a great accomplishment! In moving forward with this idea of a text rpg game I decided to look in the various sections of gamedev.net and see their is no help involved with making a text based game. Unless I am blind? =) I just was wondering how one would go about structuring this program? I was wondering is it possible to use to read in from a .txt file the various story plots? Example would be a new paragraph for each room or area you enter would display a new paragraph to describe the area? Is this possible? I have messed around with reading in info from a file for college but nothing to crazy just some numbers not paragraphs of info! Then, when this person picks up a weapon or item how should I store them? I think something like this but I am not sure?
struct player
{
string weapon1;
string weapon2;
string armor1;
string armor2;
string potion1;
string potion2;
string potion3;
int gold;
};
Will this suck up a lot of memory using strings or if I use class instead of struct? I was told classes use more memory and are slower than structs? Is their a way to use char instead? Also when the player is done and wants to save his game all my variables need to get saved to a .sav file, I should be able to use the header and save all my variables or not? I would really like to see some tutorials on this simple idea of a game but for newbie game coders it isn't! Thanks =8)
Windows 98/SE/ME SUCKS!
Deal with it!
if(windows crashes)
run Linux
else
yeah right!!
RESIST WINDOWS XP!!!!!!!!!!
RESIST .NET TECH!!!!!!!!!!!
Edited by - felisandria on May 27, 2001 2:32:05 AM
Edited by - MARS_999 on May 27, 2001 8:47:01 PM
It would be best to have the game structured into different states: main menu state, game state, save/load game state, battle state, etc. This keeps the game design structured. You''ll have to create a little text parser to be able to interpret anything the user types, or if you prefer something similar to left arrow = move left, right arrow = move right, and eliminate the need for text parsing, thats ok too. As for the player structure, you should use classes to make a heiarchy of the items and enemies in the game, as well as maybe making a CGame class to overhang everything. That way, you can have something like CKnife derived from anther class CItem, or whatever. Then you can have maybe like 10 inventory slots on the player, each being a CItem type, so the player can have many types of items on him. THese are just some thoughts that popped to the top of my head. DOnt know of any tuturials on the subject though.
For an interesting article on test game design, check out badcontent. Diary of a Bad Game programming could be pretty useful. BC is my site, btw, so that was an official Shameless Plug
![](smile.gif)
Hey Zipster I am new to classes because I have not used them before. I have always used struct''s instead. I have this much down though
class player
{
private:
int gold;
int health;
int experience_level = 1000; //make this up for now
public:
void getinfo(void)
{
cin >> gold;
cin >> health;
}
void show(void)
{
cout << experience_level;
}
};
player currentplayer;
currentplayer.getinfo();
currentplayer.show();
Ok think that should do, I know this isn''t a great example but what my question is what is a constructor and a deconstructor? Do I need them for situations like the one above? I also was wondering are classes faster and do they use less memory than struct''s? I have looked in the gamedev.net info section and see nothing on classes benefits over a struct? Thanks again!
Windows 98/SE/ME SUCKS!
Deal with it!
if(windows crashes)
run Linux
else
yeah right!!
RESIST WINDOWS XP!!!!!!!!!!
RESIST .NET TECH!!!!!!!!!!!
class player
{
private:
int gold;
int health;
int experience_level = 1000; //make this up for now
public:
void getinfo(void)
{
cin >> gold;
cin >> health;
}
void show(void)
{
cout << experience_level;
}
};
player currentplayer;
currentplayer.getinfo();
currentplayer.show();
Ok think that should do, I know this isn''t a great example but what my question is what is a constructor and a deconstructor? Do I need them for situations like the one above? I also was wondering are classes faster and do they use less memory than struct''s? I have looked in the gamedev.net info section and see nothing on classes benefits over a struct? Thanks again!
Windows 98/SE/ME SUCKS!
Deal with it!
if(windows crashes)
run Linux
else
yeah right!!
RESIST WINDOWS XP!!!!!!!!!!
RESIST .NET TECH!!!!!!!!!!!
In C++, classes and structs are the exact same thing, with one exception: the default access-modifier. The default access-modifier for a class is ''private'', while it is ''public'' for a struct.
There is no difference in speed or memory usage.
There is no difference in speed or memory usage.
I don''t know if structs can have constructors or destructors; I''ve never used them that way before. But what they do: a constructor is the function that is called directly after the class is put into memory. It basically sets up any variables in the class that you want to have default values, or any functions you want called before the class is used, etc. A deconstructor is the opposite. It''s called right before the class is removed from memory. It does things like delocate any memory that the class might have allocated, etc. The constructor function has the same name as the class, and the deconstructor has the name of the class with a tilde (~) in front. So if we have class CStuff, the constructor would be CStuff::CStuff, and the deconstructor would be CStuff::~CStuff. Also note: if you don''t specifically delcare a constructor or deconstructor, the compiler makes one for you; basically an empty brace function. That way all classes have constructors and deconstructors whether you know it or not!
![](smile.gif)
Yeah, I see that my compiler is letting me use classes without using a constructor and a deconstructor! Thanks again!
Windows 98/SE/ME SUCKS!
Deal with it!
if(windows crashes)
run Linux
else
yeah right!!
RESIST WINDOWS XP!!!!!!!!!!
RESIST .NET TECH!!!!!!!!!!!
Windows 98/SE/ME SUCKS!
Deal with it!
if(windows crashes)
run Linux
else
yeah right!!
RESIST WINDOWS XP!!!!!!!!!!
RESIST .NET TECH!!!!!!!!!!!
Try looking at some code/documentations on a MUD server
(http://www.ironfroggy.com/)(http://www.ironfroggy.com/pinch)
Hehehehe! Katakana is fun
BADOCONTENTO
Gaiomard Dragon
-===(UDIC)===-
BADOCONTENTO
![](smile.gif)
Gaiomard Dragon
-===(UDIC)===-
Gaiomard Dragon-===(UDIC)===-
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement