delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/03/30/01:44:24

From: "John M. Aldrich" <fighteer AT cs DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Big Programs
Date: Sat, 29 Mar 1997 02:14:15 -0800
Organization: Two pounds of chaos and a pinch of salt
Lines: 36
Message-ID: <333CEB77.119@cs.com>
References: <19970328233735555 DOT AAA189 AT ns1 DOT megsinet DOT net>
Reply-To: fighteer AT cs DOT com
NNTP-Posting-Host: ppp215.cs.com
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019