Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Rob Loach

Segmenting Game Classes

This topic is 5576 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I''m beginning a new game and am wondering how I should segment it (C++). Should I have a .cpp file called: - CObjects: all game objects/classes that don''t have to do with any data input/output (Player class, monster class, item class, etc) - CInput: All engine stuff to have data input (user, file, etc) - COutput: All engine stuff to do with data output (Console display, file output, etc) - CMain: Holds int main.... Anyone have any suggestions on how to segment them in a good way?
Rob Loach Current Project: Go Through Object-Oriented Programming in C++ by Robert Lafore "The question is not how far, the question is do you possess the constitution, the depth of faith, to go as far as is needed?" - The Boondock Saints

Share this post


Link to post
Share on other sites
Advertisement
There''s no right or wrong way of organizing a project, but there are shitty ways. I don''t really like your "CInput" or "COutput" files. A good rule is give each class it''s own .cpp/.h files.

Here''s an oversimplified version of mine:

CGraphics - Graphics subsystem
CSound - Sound subsystem
CObject - Generic object class. All game objects (CUnit, CStructure, etc.) derive from this
CGameMap - Holds a map
CInput - Input subsystem

There are of course other, smaller classes that have their own files (e.g. CTexture, which goes with CGraphics), but you should get the idea.

The main code in the game just inits CGraphics, CInput, and CSound then loads up all the needed graphics, and sounds. When a game is started, a map is loaded, and the default objects are spawned onto the map.

Share this post


Link to post
Share on other sites
And all the *.h files of the *.cpp files do are hold the predirectives of all those classes?



Rob Loach
Current Project: Go Through Object-Oriented Programming in C++ by Robert Lafore

"The question is not how far, the question is do you possess the constitution, the depth of faith, to go as far as is needed?"
- The Boondock Saints

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!