C++, Laying out a game...
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 :)
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 :(
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 :(
Try a switch, function pointers, or virtual functions.
For now, just keep writing code, it'll get easier.
For now, just keep writing code, it'll get easier.
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.
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)
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)
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement