Archived

This topic is now archived and is closed to further replies.

Eckker

Ideas for structuring code

Recommended Posts

Eckker    122
Greetings. I''ve been learning C++ from a number of books and have decided to learn Direct X. I now feel ready to try to program my first game... I thought a Pong clone(sticking to tradition). My queries are really where to begin and how my code should be set out and how code in games is set out generally. If anybody could point me in the direction of an article on the subject or a good book, or any words of advice, it would be most appreciated. I''ve looked through the forum and didn''t find what I was looking for.

Share this post


Link to post
Share on other sites
Jindocai    122
Well it seems to me you''re trying to bite off more than you are able. If you don''t know how to design a pong game than learning directx should be the least of your worries. I''d suggest you work on program design and implementation before moving on to advanced and generally headache inducing libraries.

However if you wish to keep moving forward be aware that directx shouldn''t have much effect on how you make a game. The kicker is going to be the fact you are in windows. I hope you are familiar with the windows message pump and all that. My advice is to skip directx all together and use SDL or even openGL since they allow for more pure programming without worrying about OS structures. However if you are still set here is how I would lay it out.

have several classes

the app class, the input class, the engine class, the render class, the data class and the objects classes.

app-class includes all windows and directx initalization stuff and also has message loops etc.

the input class uses dinput to send input to the engine class to make decisions

the engine class is the brains of the operation who decides every action from menu selections to game physics etc

the render class is incharge of drawing the schene. ie directx graphics stuff

the data class stores any data you want to use with the game as well as stuff you want to store (high scores for example)

the object classes, you will probably want the paddles, ball(s) and board to be objects if you are doing true OO design.

making this all works may be out of the scope of your desires. However to start I''d focus on the underlaying engine design and build out words.

There are several books for beginners which should help and they often include walkthroughs how to make a complete (all be it crapy) game







Share this post


Link to post
Share on other sites