RPG Project

This is a discussion on RPG Project within the A Brief History of Cprogramming.com forums, part of the Community Boards category; Hello everyone, I am currently working on a RPG console project, and would like to know a few things: [list=1][*]How ...

  1. #1
    I am the worst best coder Quantrizi's Avatar
    Join Date
    Mar 2002
    Posts
    644

    RPG Project

    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.

  2. #2
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    Code:
    //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;
    }
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  3. #3
    I am the worst best coder Quantrizi's Avatar
    Join Date
    Mar 2002
    Posts
    644
    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.
    Last edited by Quantrizi; 03-25-2002 at 02:13 PM.

  4. #4
    Super Moderator
    Join Date
    Sep 2001
    Posts
    4,913
    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.

  5. #5
    Unregistered
    Guest
    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...

  6. #6
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    Oh, and the reply above would be from me ...

  7. #7
    muttski
    Guest
    Hey magos, we should play on bnet sometime, email me if you want.

    ramso13@email.com

  8. #8
    I am the worst best coder Quantrizi's Avatar
    Join Date
    Mar 2002
    Posts
    644
    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?)

  9. #9
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    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:
    Code:
    while(1)
    {
      printf("Enter name:");
      gets(Name); //Whatever syntax gets has
      printf("Enter class:");
      gets(Class);
    }
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  10. #10
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    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...
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  11. #11
    muttski
    Guest
    You got selected as a tester, lucky.

  12. #12
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    Originally posted by muttski
    You got selected as a tester, lucky.
    When I live in sweden? I don't think so ...
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  13. #13
    I am the worst best coder Quantrizi's Avatar
    Join Date
    Mar 2002
    Posts
    644
    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:
    Code:
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. problem
    By ExDHaos in forum C++ Programming
    Replies: 12
    Last Post: 05-22-2009, 04:50 AM
  2. Problem Displaying a Struct
    By rockstarpirate in forum C++ Programming
    Replies: 16
    Last Post: 05-05-2008, 09:05 AM
  3. 2D RPG Online Game Project. 30% Complete. To be released and marketed.
    By drallstars in forum Projects and Job Recruitment
    Replies: 2
    Last Post: 10-28-2006, 12:48 AM
  4. Need assistance for major text base Arena RPG project
    By Ruflano in forum C++ Programming
    Replies: 0
    Last Post: 04-04-2002, 10:11 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21