Game Programming and Development Tools

Input on my Engine – renegader_bj

renegader_bj
Member

Posts: 23
From: WI,USA
Registered: 07-30-2007
Well guys, I'm fairly new to programming in C++ and directX, and I've been doing fairly well. I've worked my way throught several books on the subject, but now I am confused about something.

A book I am working through used a method of writing that use direct call instead of long pointers (ex. LPDIRECT3DDEVICE9 vs. Idirect3Ddevice9: Anyway, this book also uses the class system, whereas the other book used simple .h and .cpp files with no class implementation; if this is a confusing explanation I can upload some example code. Anyway, they both work, but the class system engine example is 4 times as large as the other version I described.

Both systems seem to work perfectly, but the one without the huge class systems is much smaller but seems to do the exact same thing! I wrote a test engine ( the one I used to program Falling Sheep!), implementing the non-class system. But is that the right way?

The example of the class system graphics engine in my book is huge, and I don't know if all that's neccessary or if I've been learning wrong all along.

The reason I'm asking is I know commercial engines aren't as small as my test engine, and I think they use the class system...do they?

Please Help!

[This message has been edited by renegader_bj (edited August 22, 2007).]

samw3

Member

Posts: 542
From: Toccoa, GA, USA
Registered: 08-15-2006
What you are discovering is object orientation. Often coding in oop seems larger at first, and with small examples it is larger, but in the long run it is smaller and/or easier to manage than monolithic or procedural code. For instance, kenman's speed game took over 10,000 lines and is coded in a monolithic style. My final code base, for Finding Adina, was 6420 lines.

So, I'd say in the long run is use the class system and really learn object orientation.

Here's a quick google of "c++ object orientation tutorial"

The first link looks like a good start. I will be happy to answer questions as I have time.

God Bless!

------------------
Sam Washburn

Check out my CCN SpeedGame 2 Blog

[This message has been edited by samw3 (edited August 22, 2007).]

HeardTheWord

Member

Posts: 224
From: Des Moines, IA
Registered: 08-16-2004
Hey renegader_bj,

Quite a few game engines are starting to use the class, or Object Oriented, approach to designing their code. There are several benefits to coding this way but as you mentioned it requires a bit more code than just calling procedures. The main benefit, in my mind, is something called encapsulation. This keeps the different systems separated from each other in the engine. For example, you could keep your graphics code separated from the rest of your logic so that when you want to add OpenGL functionality it should be a much easier task than rewriting your entire graphics system. This also will save you from the headache of having to test DirectX again.

Honestly, as you noted, it doesn't matter which method you use to program with. There are benefits to both methods but really it depends on what you are comfortable with. I would highly suggest looking into OOP but continue to learn what you are doing now. Either way the end product will look the same it's just a matter of being able to dig through the code a year from now.

Practice, practice, practice and you'll find that over time you make better design decisions.

renegader_bj
Member

Posts: 23
From: WI,USA
Registered: 07-30-2007
Thanks you guys! I finally know what OOP is! I also have names to place with what I was doing, and I have an answer to my question. You guys are Awesome!!!