C++, Laying out a game...

Started by
13 comments, last by stylin 18 years, 8 months ago
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 :)
-www.freewebs.com/tm1rbrt -> check out my gameboy emulator ( worklog updated regularly )
Advertisement
Have a look at ORGE or Auran Jet.
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
He means OGRE, not ORGE.
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]
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 :(
-www.freewebs.com/tm1rbrt -> check out my gameboy emulator ( worklog updated regularly )
Try a switch, function pointers, or virtual functions.
For now, just keep writing code, it'll get easier.
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
Try a state machine (which is a design pattern) for the specific example you showed there.
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.
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)
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
-www.freewebs.com/tm1rbrt -> check out my gameboy emulator ( worklog updated regularly )

This topic is closed to new replies.

Advertisement