Advertisement

Code Layout

Started by March 28, 2000 01:27 PM
2 comments, last by kieren_j 24 years, 5 months ago
As I programmed my first game, I began to realize that 79.3kb was a bit big for all the code. So, I invented my own little code-module system. Basically, I have a file called "init_shutdown.cpp" that deals with initialization and shutting down, a file called "frame.cpp" that deals with state selection and basic rendering. For my global objects (i.e. sprite structures) I create a file called "objects.cpp" that contains things like:

// sprites
Sprite sprite_1;
Sprite sprite_2;

// models
Object rings;
 
And then I create an "objects.h" file like below, and place an #include "objects.h" in my precompiled-header file.

// sprites
extern Sprite sprite_1;
extern Sprite sprite_2;

// models
extern Object rings;
 
However, I''m not sure this is the most efficent method... what do YOU use? thx
Do what works for you. As long as it is the same code, just cut up into different files, you''re not going to get a speed increase from the executable. Modularize your code in a way that makes it easy to find the functions that you use and is understandable to you. Besides, the way you do it is pretty much the same way most people do it.

Domini
Advertisement
I use one header to complement one CPP file:
header declares stuff and prototypes of the cPP file, while the matching cpp file has the executable code. It makes a lot of files, but if you''re trying to find a function, scanning the .h files is really quick instead of the whole cpp file.
___________________________Freeware development:ruinedsoft.com
This is only sort of related, but god bless VC++ for the classView, with easy navigation of functions...

J2xC

------------------------------
About time I put something funny here? I think so too...
J2xC (J. Connolly) Ah! By popular demand, I shall no longer resist...

This topic is closed to new replies.

Advertisement