Skip to main content
GameDev.net gamedev.net
🔒 Locked

game programming question

Started by theadamSGT Jul 24, 2005 at 9:47 PM 23 replies 2.9k views
Original Post
theadamSGT
theadamSGT
i was wondering how do you split the source code into more files
theadamSGT
theadamSGT
thats what i want to do but it doesnt say how
ProPuke
ProPuke
You create a new sourcefile.. you place or move code into it..

You usually share functions across sourcefiles using shared headers containing the function declarations, & share variables by including the variable declarations preceeded with the "extern" keyword in them (the headers)
Once again classes & structures are shared in the same manor - the declarations are usually placed in the headers & the definitions are written in specific sourcefiles
when the sourcecode goes through the linking stage (after each file is compiled) all of this is magically reconnected again

It was a terribly general question so I'm afraid I wasn't sure entirely how to answer ..

Somethings are best learnt by delving in & trying yourself until things eventually "click"
(they're usually the things taken for granted as simple common knowledge afterwards);
those things are usually the hardest to explain because of that ;]
____ _ ___ ___ __ _`By offloading cognitive load to the computer, programmers are able to design more elegant systems' - Unununium OS regarding Python
theadamSGT
theadamSGT
i sort of knew that i just dont know how to do it
ProPuke
ProPuke
well if you explained the specific part you are having trouble understanding..?

Are you having trouble creating the sourcefiles themselves in the ide & adding them to the project?
____ _ ___ ___ __ _`By offloading cognitive load to the computer, programmers are able to design more elegant systems' - Unununium OS regarding Python
theadamSGT
theadamSGT
how do you post the box where you put source codes in
theadamSGT
theadamSGT
i dont know what headers to include andwhere to put stuff like that
thallish
thallish
in between [#source][#/source] without the # (that's the general tags)

other useful stuff is in the forum faq

regards

/thallish
regards/thallishI don't care if I'm known, I'd rather people know me
Sly
Sly
Small steps, dude. Small steps. Learn to program small applications before diving head-first into games programming. get one of those "Learn C in 21 Days" books or something and start there, slowly building up to simple games like Pong.
adamggg
adamggg
Try this article:

http://www.gamedev.net/reference/articles/article1228.asp
theadamSGT
theadamSGT
well the problem is i dont know what to put in the source codes
SiCrane
SiCrane
Moved to the For Beginners forum. Keep in mind that this means that the newbie protection rules are in effect.
CJWR
CJWR
Quote:
Original post by SiCrane
Moved to the For Beginners forum. Keep in mind that this means that the newbie protection rules are in effect.


what are the newbie protection rules?!
Charles Reed, CEO of CJWR Software LLC
programwizard
programwizard
Quote:
Original post by SiCrane
A reminder for posting in For Beginners.

In case you don't want to follow the link, that means no flaming, laughing at, making fun of, etc. People in the game programming forum would probably tear this guy up for asking a question like that. Here, you can ask anything you like! To the OP: you simply put some of your code in one file and the rest in another. You still have to #include all the necessary include files though. Doing this is called making a project. Unless your using a command-line compiler, you should see an option for creating a new project in the File menu. When you compile the project, all of your different sources are pulled together. You probably don't want to know this, but Microsoft Visual Studio allows you to create things called Solutions, which split up uber long programs into multiple projects. Fortunately, unless you combining two totally different app types, like MFC for a GUI and Win32 for the code, a game usually only needs one project.

------------------------------Support the Blue Skies in Games Campaign!A blog... of sorts.As a general rule, if you don't have a general rule in your signature, you aren't as awesome as someone who does. General rules roxor teh big one one ones.
theadamSGT
theadamSGT
does anyone have an example and can the for Beginners forum have general programming and game programming?
adamggg
adamggg
What language and what compiler are you using?
theadamSGT
theadamSGT
c++ with the dev c++ compiler

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.