Jump to content
  • Advertisement
Sign in to follow this  
ErUs

C++, Laying out a game...

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

ok, hello again. i now know C++ well, but i have real problems laying out classes for any sort of game. for instance; i don't know what to put in classes and what not to and i don't know how to set up a system were different classes can look at other classes when i try and make stuff scalable ( array of classes ). i would like to see how you guys set up your games. do you have a MainLoop function in a class? do you put rendering code in its class own class? input? menu/ingame? thanks alot ( i know its a hard post to reply to but i really cant simplify what im saying. ) [edit] class layouts - in ascii graphics or graphs :)

Share this post


Link to post
Share on other sites
Advertisement
Try not to get stuck by considering too far ahead. My projects always go downhill as I try to get the best design for everything, when in fact there is no "best" design. Just design your first couple of projects incrementally and soon you'll pick up the knack for joining the parts together. [smile]

Share this post


Link to post
Share on other sites
i dont think you guys got what i was saying...

i end up doing stupid stuff like

if( gamemode == TITLE1 ) {
doTitle1();
} elseif( gamemode == TITLE2 ) {
gamemode = title3;
} elseif( gamemode == TWOPLAYER ) {
blah blah

and its very very messy :(

Share this post


Link to post
Share on other sites
Try a state machine (which is a design pattern) for the specific example you showed there.

Share this post


Link to post
Share on other sites
Shannon Barber and Squirm, I think he was talking in general.

You can search about refactoring, which is basically modifying the design of your code before writing new code. Design pattens might help too.

Listen to Kuladus, he's right. There is no such thing as best design. This doesn't mean you shouldn't design, it means you can't design everything and think everything will flow. Again, as Kuladus said you should not "consider too far ahead". Designing and coding goes hand in hand; you design a little, you program a little. Repeat the process until completion.

As with everything, the more you do it, the better you get at it. The more you design, the better you will become at it. You will notice patterns, and/or you will be able to create new designs from past designs.


Darkneon

P.S What I mean by design is diagrams and pseudocode.

Share this post


Link to post
Share on other sites
I vote for a multiple-pass approach: first, just use whatever techniques come to mind to actually make working features (don't think about the code design too much at first). You will run into problems in the design, but when you look at what you end up writing, you learn what went right and what went wrong.

After you understand a lot of things that work/don't work, look up books on "Design Patterns". Basically, they are compilations of various "what works and what doesn't" that are really common in programming. After you let all of that information sink in, you should be able to figure out really good ways to design your overall game systems.


Note: This process took about 8 years for me (from when I started using C++ as a newbie to what I know now)

Share this post


Link to post
Share on other sites
ok thanks guys.

im gonna try and design a bit; code a bit; repeat;

and get a few books.

also i looked at function pointers and state paterns and i will apply where necessary

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!