Split code into two files

Jun 3, 2011 at 9:40pm
I am trying try split my code into 2 files. What I want to do I split the game up so that each dungeon is in a different file. The dungeons include the shape, size, and controls.Is this possible. If so how?
Jun 3, 2011 at 9:47pm
closed account (zb0S216C)
Do you mean data files that hold game information, or C/C++ header files?

Wazzak
Jun 3, 2011 at 9:50pm
data files(.cpp) that hold the commands.
Jun 3, 2011 at 9:58pm
closed account (zb0S216C)
My personal suggestion be this:

Writing game data to files would be far more beneficial as it allows data modification without the need to recompile after every change.

However, if you insist on using source files, fair enough. What you could do is add multiple sub-structures to your current dungeon class and divide your information that way.

Honestly, that's the only way I can think of, without running into multiple inclusion errors. Can you be a bit more specific? Maybe that way, I can help you more.

Wazzak
Jun 3, 2011 at 10:17pm
I will just put in in one file. But later on in my game I will put other things in other files cause my dungeon file has 2765 lines in it. So i guess later on I will make that way but my personnel deadline is this weekend for my demo
Jun 3, 2011 at 10:27pm
closed account (zb0S216C)
If you're putting into one file then I suggest you follow what I said in my previous post. Adding sub-structures to a structure tends to make it more readable. For example:

1
2
3
4
5
6
7
struct Character
{
    struct _Position
    {
        float x, y, z;
    } Position;
};


Wazzak
Jun 4, 2011 at 6:29am
This is my same question. I downloaded an Open Source software called Code::Blocks. Its divided into many .cpp and header files. I need to know how to combine them together to form one program.
Topic archived. No new replies allowed.