Mail Archives: djgpp/1997/03/30/01:44:24
Paul Schmidt wrote:
>
> I have a game source file that is really big and I would like to split it up
> into multiple files...how would I do this?
First, split up the code into sets of related functions. Put all
low-level graphics functions into one source file, all file handling
code into another, the main game loop into another, etc. Then write one
or more header files that contain the global declarations that all these
files have in common. Include this header file in each source file.
Then you can either compile all the modules together by just putting
them all on the command line at once, or you can write a makefile to
build each part of the source only as needed. For an example of such a
makefile, email me.
A tip: In general it's far easier to start out with a modular design
than to reverse-engineer it, so to speak, from a single huge source
file. For examples of this sort of thing, look at any medium-to-large
software package (like the ones that come with DJGPP) and note the
various ways that the code is broken up. Examine the header files to
see how they are put together. Look at the makefiles to see how they
build these projects in individual pieces, and allow you to add or
remove modules just by changing one or two lines. Experiment and
learn. ;)
hth
--
John M. Aldrich, aka Fighteer I <fighteer AT cs DOT com>
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCS d- s+:- a-->? c++>$ U@>++$ p>+ L>++ E>++ W++ N++ o+>++ K? w(---)
O- M-- V? PS+ PE Y+ PGP- t+(-) 5- X- R+(++) tv+() b+++ DI++ D++ G>++
e(*)>++++ h!() !r !y+()
------END GEEK CODE BLOCK------
- Raw text -