Jump to content
  • Advertisement

Archived

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

Metus

OOP Game Coding

This topic is 6077 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

Hello out there. I''ve been conding on my OOP Game for a couple of weeks now, but now, I''ve found out that my "engine" is to "big". I''ve got one class for Input, one class for Video and one class for Audio. As i told you I find that pretty messy. How do you guys write your engines? one class for the entire engine or splitted lik I am?

Share this post


Link to post
Share on other sites
Advertisement
have a class for everything, thats what oop is...

your "engine" class should be split up into, for example, a texture class, a mesh class, a terrain class, a camera class, a file io class, a maths class, and a physics class.

Share this post


Link to post
Share on other sites
That''s precisely how me and my coding group organized our game. Every instance of the game had an Audio Engine class initialized, for example.

Share this post


Link to post
Share on other sites
quote:
Original post by Smurfwow
have a class for everything, thats what oop is...

Not. Have a class for every logically distinct object that can be operated upon or told to operate on itself. Don''t have a class for the sake of having a class, or have classes that consist of nothing but static methods (ie, use classes as means of "organizing" code). That''s what namespaces are for.

[ GDNet Start Here | GDNet Search Tool | GDNet FAQ | MS RTFM [MSDN] | SGI STL Docs | Google! | Asking Smart Questions | Internet Acronyms ]
Thanks to Kylotan for the idea!

Share this post


Link to post
Share on other sites
Ok, so since each part of the engines (Input, Video, Audio) often needs access to same things it SHOULD be ok to consider the while engine as ONE class instead of THREE?

Share this post


Link to post
Share on other sites
No.

Better add another class containing the game data.

So you would have
Audio
Graphic
I/O
WorldRepresentation

The last contains all game relevant data and has access functions to manipulate and read the data.

Share this post


Link to post
Share on other sites
Using OOP in a game system can be somewhat difficult at times. I know I reworked my first OO engine multiple times to allow for minium globals and loosely coupled behaviour.

Right now I have:
XGameObj
XBitmap
XTileSet
XInput
and a DirectX wrapper.

I might even get less complicated soon.

Share this post


Link to post
Share on other sites
quote:
Original post by Nali
how does namespaces work ?

Namespaces prevent identifier collisions (like when you and I both write a function named Find with the same number and type of parameters, or when we both have a class name Graphics). They also promote "localization", for lack of a better word.

Search the web for more info.

[ GDNet Start Here | GDNet Search Tool | GDNet FAQ | MS RTFM [MSDN] | SGI STL Docs | Google! | Asking Smart Questions | Internet Acronyms ]
Thanks to Kylotan for the idea!

Share this post


Link to post
Share on other sites
Bets way to program is no classes and write everything in the WinMain function, all in one source file. If your game uses other functions and classes, then it''s not a cool game

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!