Sign in to follow this  

In Regards to Program Design.

This topic is 3624 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 gamedev. Recently I have been doing some graphical programming in SDL using Lazyfoo as my guide. I understand the concepts there but, when I try to blend them together to form an actual game it turns into a mess. I can never get a good Class-based design going in my games. I can get small demos up and running but, when I try to seperate concepts like Graphics, Input, Engine, ect into classes it never works out for me. I am wondering if anyone knows a good tutorial or reference I can use that would help me with the program design of games. I have downloaded source code for some Direct X games but, the code is either too little commented to make use of or doesn't resemble SDL enough for me to understand in an SDL context. Thank you.

Share this post


Link to post
Share on other sites
Your question is pretty hard to answer (at least for me). I think that it would be better if you first complete a game. It should be something fairly simple (the classics are pong, breakout, tetris and snake), and you should focus more on getting it done, and less on doing it well. After that, you can post the source code here and people will be able to give you more specific advice and suggestions for improvement. I think this can be a great way to learn.

As far as OOP design goes, I'm far from being an expert, but a simple process that should get you started is this:


  • Decide what objects you'll need and what interfaces they'll have. A quick way to do this is to write down a description of your program and look for nouns and verbs. The nouns are objects, and the verbs are operations that they perform. This will give you an initial list of objects, and later you'll probably discover that you'll need more, but at this point you can start implementing something.

  • Decide how the objects will communicate with each other. For example, an object A can communicate with object B (i.e., call a member function) by creating an instance of A (as a class member or as a local variable in a member function), or it can be passed a pointer/reference to A, in the constructor or in a member function (whichever is more appropriate in that particular sitation).

  • Look for common features between objects. This can be a good opportunity to use inheritance and virtual functions (but don't overdo it).

  • Try to design your classes so that each has a single responsibility, that is, each class should only be responsible for doing one thing (more on this). This can be difficult without some experience, so don't worry if you're not sure how to accomplish this, but it's something to keep in mind when designing your classes.



This is very simplified, and there are probably many things I left out, but I think it can be a good start. Also, look at some of the articles in the first link in my sig (under the category Object-Oriented Design). Some of them can be hard to grasp for a beginner, but they might give you further directions to explore.

Good luck.

Share this post


Link to post
Share on other sites
The first step in solving the problem is identifying the problem. What are you trying now and why are your current attempts not working out? What in particular seems to be the problem (or a symptom of the problem)?

Share this post


Link to post
Share on other sites
Seems like you have the main idea of separating the main modules (graphics, input, sound, etc.). Then just pick one and start splitting it, e.g. graphics -> graphics api -> opengl and so on. Don't try to add too many features at once, create something working first. :)

Share this post


Link to post
Share on other sites

This topic is 3624 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this