c++ noob making a game

This is a discussion on c++ noob making a game within the Game Programming forums, part of the General Programming Boards category; hmm few more questions, if u have many save files how do you get your program to say look in ...

  1. #16
    Registered User
    Join Date
    Oct 2003
    Posts
    9
    hmm few more questions, if u have many save files how do you get your program to say look in a directory and then make a list of all the files in that directory and then allow you to load them?

  2. #17
    Spaced Cadet
    Join Date
    Aug 2003
    Posts
    110
    There is a way to read a directory, but you'll have too look for the tutorial yourself, but I personally open two files on save time (one if the save already exists) one has a list of all the saves, the other is the actual save file. Lame way of doing this, but it works.

  3. #18
    Registered User
    Join Date
    Oct 2003
    Posts
    9
    Originally posted by Dark Nemesis
    There is a way to read a directory, but you'll have too look for the tutorial yourself, but I personally open two files on save time (one if the save already exists) one has a list of all the saves, the other is the actual save file. Lame way of doing this, but it works.
    Well if I can't find a tutorial I'll keep that in mind, thanks again.

  4. #19
    Registered User
    Join Date
    Sep 2003
    Posts
    8
    Why do you have multiple save files? Why dont you just save all the data onto one save file? It would look like this:

    Code:
    #include <iostream.h>
    #include <fstream.h>
    
    int main()
    {
     int hp=100, exp=2000, lvl=10;
     
     ofstream save("save.ini");
     save << hp << "\n" << exp << "\n" >> lvl;
     save.close();
     
     hp=0;exp=0;lvl=0;
    
     ifstream read("save.ini");
     read>>hp;
     read>>exp;
     read>>lvl;
     read.close();
     cout<<hp<<" "<<exp<<" "<<lvl<<endl;
     system("PAUSE");
     return 0;
    }
    Should look like this once compiled:

    Code:
    100 2000 10
    Press any key to continue...

    Hope I helped
    Last edited by Newbie Magic; 11-22-2003 at 02:30 PM.

  5. #20
    Registered User
    Join Date
    Sep 2003
    Posts
    8
    Here is a program that I made a little while ago using that save method (it is saved in hex so it may look different):
    LevelUp.zip

  6. #21
    Registered User Mokkan's Avatar
    Join Date
    Oct 2003
    Posts
    20
    That's a cool program . Good job on the lvl up.

  7. #22
    Rabite SirCrono6's Avatar
    Join Date
    Nov 2003
    Location
    California, US
    Posts
    269

    Post

    You shouldn't use system("CLS") to clear the screen, go to the C++ board and look at Clearing Text if you want.

    Also, instead of:

    Code:
    using namepsace std;
    Use:

    Code:
    using std::cin;
    using std::cout;
    using std::endl;
    ...
    Probably other using std's but that's all I've had to use in my simple programs...

    Oh, yeah. Instead of:

    Code:
    #include <iostream.h> //Deprecated header.
    Use:

    Code:
    #include <iostream> //Correct header.
    Edit: Oh! Oops! Someone already said about the deprecated/correct headers!
    Last edited by SirCrono6; 11-27-2003 at 11:20 AM.
    From C to shining C++!

    Great graphics, sounds, algorithms, AI, pathfinding, visual effects, cutscenes, etc., etc. do NOT make a good game.
    - Bubba

    IDE and Compiler - Code::Blocks with MinGW
    Operating System - Windows XP Professional x64 Edition

  8. #23
    Registered User
    Join Date
    May 2003
    Posts
    195
    what s the diff between using namespace std and the deprecated header i dont get it

  9. #24
    Rabite SirCrono6's Avatar
    Join Date
    Nov 2003
    Location
    California, US
    Posts
    269
    It's all part of programming better, and to the standard...
    From C to shining C++!

    Great graphics, sounds, algorithms, AI, pathfinding, visual effects, cutscenes, etc., etc. do NOT make a good game.
    - Bubba

    IDE and Compiler - Code::Blocks with MinGW
    Operating System - Windows XP Professional x64 Edition

  10. #25
    Rabite SirCrono6's Avatar
    Join Date
    Nov 2003
    Location
    California, US
    Posts
    269
    If you did this just a little after learning C++ then what did you use to learn? Books? Online tutorials? If so, which one did you use? I can do a little C++ but don't understand it that much. It looks like you got it fine and I want to make stuff like that too. So what did you use, or what would you reccomend for me to learn C++ better?
    From C to shining C++!

    Great graphics, sounds, algorithms, AI, pathfinding, visual effects, cutscenes, etc., etc. do NOT make a good game.
    - Bubba

    IDE and Compiler - Code::Blocks with MinGW
    Operating System - Windows XP Professional x64 Edition

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. 20q game problems
    By Nexus-ZERO in forum C Programming
    Replies: 24
    Last Post: 12-17-2008, 04:48 PM
  2. beach bar (sims type game)
    By DrKillPatient in forum Game Programming
    Replies: 1
    Last Post: 03-06-2006, 12:32 PM
  3. PC Game project requires c++ programmers
    By drallstars in forum Projects and Job Recruitment
    Replies: 2
    Last Post: 02-21-2006, 11:23 PM
  4. Game Engine Link Prob
    By swgh in forum Game Programming
    Replies: 2
    Last Post: 01-25-2006, 11:14 PM
  5. Lets Play Money Making Game
    By ggs in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 09-04-2001, 08:36 PM

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