Need help with C++

How do you save your variables in a file in C++. Im talking it this year and me and a friend are doing a side project and we want the ability to save… We only need variables saved not anything else.

Thanks!

Also if you can help me understand how you can run an image thing in C++ like a max picture that would help to

Well, there’s no way to just do something like
saveAllVariables()
loadAllVariables()

but you can just write them all out to a file one by one:

ofstream ofs;
ofs.open(“out.txt”, ios::out);
if(!ofs){
//error stuff goes here
}

ofs << var1 << ’ ’ << var2 << ’ ’ << var3 << etc, etc;

ofs.close();

and then to read it back in:

ifstream ifs(“out.txt”);
if(!ifs)
//error stuff

ifs >> var1 >> var2 >> var3 >> etc,etc;

Let me know if you need anything else.

-Rob

yes but rob, t-ton and I would like to know how to run 3d images and manipulate things in 3d like you can do in 3ds max. we are making an rpg.

Also what header files are needed to compile the above code?

yes but rob, t-ton and I would like to know how to run 3d images and manipulate things in 3d like you can do in 3ds max. we are making an rpg.

Well, if you want to manipulate an image, it depends what type of image file it is, ie., what format it is. To take a more general approach to things, and since you say it is for a game, might I suggest looking at OpenGL or CrystalSpace or any of a variety of graphics engines.

Also what header files are needed to compile the above code?

All it uses is streams, so it would probably be a good bet that you’d need iosream.h.

also is there any way to change the color of text in a dos window? We will look into openGL, have you uesd it before? if so any tips?

To use the above code you need iostream.h and fstream.h you may also needs stdlib.h, depending on what your compiler includes automatically, etc.

As for image stuff, C++ won’t do it by itself, so you’re going to need some kind of library. If you could give some more specifics as to what you’re trying to do, I’d be more than happy to point you in the right direction. For starters, given that you seem to be creating a game, check out gamedev.net. They’ve got some really good tutorials/howtos, and their discussion boards are incredibly helpful.

-Rob

yea we are working on an rpg. T-ton and I want to use 3ds max and make the code let you run around and do stuff like in any other rpg like asheron’s call or Star wars Galaxies and such.

but untill we can do that we were wondering if there is any way to use … conio.h? … or something to change the color of text like they do on some muds like achaea?

Well your question isn’t one that can elicit a simple response. Unfortunately. Game programming is a tricky matter, and can get confusing if you don’t know what you are doing – or if you do!

How do you change text color? Well, you first have to decide if you want your game to work in one specific venue (such as MS), or if you want cross-platform support. You’ll need to get some libraries to work with – DirectX for Windows, and various others for varying platforms (the CrystalSpace link I posted before is a multi platform game engine with blosoming support for 3ds max … I have some experience with this, and can offer some advice if needed). From there, look into the API of the specific library you have. There are a variety of books detailing DirectX API structure, and game programming in general.

As for 3ds max support, it all depends on the library you have. It will need to have functions to read in a 3ds file – or you’ll need to get a converter to change your 3ds file to another format (such as a quake file format), and the conversion might not be absolutely perfect (computers are funny like that).

In doing a quick search on google, I came across this:

When I talk to people looking to get into game development some of the first things I often hear fall along the lines of, “How do I make games?” or “I want to make a game like Quake/Everquest/Starcraft and…”. The first is just way out of the realm of answerability, as there are too many aspects to possibly go into, and each of those components can be infinitely complex.

The second, however, falls into just being unrealistic in expectations. Starcraft, Everquest and Quake were all made by teams of professionals who had budgets usually million dollar plus. More importantly though, all of these games were made by people with a lot of experience at making games. They did not just decide to make games and turned out mega-hit games, they started out small and worked their way up. This is the point that anyone who is interested in getting into game development needs to understand and repeat, repeat, repeat until it becomes such a part of your mindset that you couldn’t possibly understand life without this self evident, universal truth.

Until you understand that all skills in game development are learned by experience, (meaning to start very small and working your way up) you will be absolutely doomed to never finish your projects. Even the infinitesimal number of teams that do manage to finish a non-trivial project before they have made any smaller ones have to learn incrementally, it just takes them many times longer than if they had started out with smaller projects.