PDA

View Full Version : RPG Project



Quantrizi
03-24-2002, 03:46 PM
Hello everyone,
I am currently working on a RPG console project, and would like to know a few things:
[list=1]
How do I save files and load the data?
[/list=1]
For the data, this is what I would like:
I want to save all of the info of the character, stuff like the name, hp, mp, max mp, max hp, stuff like that. And have the user be able to load all of that data in and like that....hope anyone understands me.

Magos
03-25-2002, 03:18 AM
//Data structure
typedef struct
{
int Hp;
int Mp;
}STATS;

int main()
{
STATS Stats;
Stats.Hp=100;
Stats.Mp=25;

//Save
FILE* SaveFile;
SaveFile=fopen("Save.sav", "wb");
if(SaveFile!=NULL)
{
fwrite(&Stats, sizeof(STATS), 1, SaveFile);
fclose(SaveFile);
}

//Load
FILE* LoadFile;
LoadFile=fopen("Save.sav", "rb");
if(LoadFile!=NULL)
{
fread(&Stats, sizeof(STATS), 1, LoadFile);
fclose(LoadFile);
}

return 0;
}

Quantrizi
03-25-2002, 02:21 PM
Thanks. Hey, I would also like to now if anyone would like to test it in about 3 weeks or so. If you do, send an e-mail to: runaway2k1@yahoo.com with the following information:

How often will you probably be playing this:
Will we give me honest comments/suggestions/etc..:

and that's it.

sean
04-03-2002, 10:24 AM
First of all, Magos, what the heck is that in your avatar....

Use fstream.h (if this is C, not C++, stdio.h, and all the f... functions (fopen, fclose, fread, fwrite, etc...). Just remember to read them in in arrays the exact same way you save. There should be a tutorial on the board about how to do this. I'd offer to try your program, but I'm going overseas for a month in 1 week. But I'd love to try it after I get back, so send it to me. My address is in my signature.

Unregistered
04-03-2002, 12:14 PM
Originally posted by Sean
First of all, Magos, what the heck is that in your avatar....
Haven't you played StarCraft? :) Its a Protoss, an alien species. The one in my avatar is called Fenix, preator of Antioch...

Magos
04-03-2002, 12:15 PM
Oh, and the reply above would be from me :)...

muttski
04-03-2002, 01:33 PM
Hey magos, we should play on bnet sometime, email me if you want.

ramso13@email.com

Quantrizi
04-03-2002, 01:46 PM
Ok, kool. I have a problem on my project though. When a user picks the class that they'll like to play as, it just recycles. This is what I mean:
A user types in there name, then types in 1 to be a mage, and as soon as the user hits the enter key, it goes back to the pick your name. It's continious(sp?)

Magos
04-03-2002, 01:55 PM
Originally posted by Quantrizi
Ok, kool. I have a problem on my project though. When a user picks the class that they'll like to play as, it just recycles. This is what I mean:
A user types in there name, then types in 1 to be a mage, and as soon as the user hits the enter key, it goes back to the pick your name. It's continious(sp?)
That is really hard to answer as we can't see your code. You use some kind of loop that never end like this:


while(1)
{
printf("Enter name:");
gets(Name); //Whatever syntax gets has
printf("Enter class:");
gets(Class);
}

Magos
04-03-2002, 01:56 PM
Originally posted by muttski
Hey magos, we should play on bnet sometime, email me if you want.

ramso13@email.com
Sorry, quit playing a while ago. I would suck now :). Currently playing War3, hope to see you there... ;)

muttski
04-03-2002, 02:09 PM
You got selected as a tester, lucky.

Magos
04-03-2002, 02:20 PM
Originally posted by muttski
You got selected as a tester, lucky.
When I live in sweden? I don't think so :)...

Quantrizi
04-03-2002, 04:00 PM
Originally posted by Magos

That is really hard to answer as we can't see your code. You use some kind of loop that never end like this:


while(1)
{
printf("Enter name:");
gets(Name); //Whatever syntax gets has
printf("Enter class:");
gets(Class);
}


This is in C++, and I got it fixed.....it had a while loop, so I just deleted it.