Skip to main content
gamedev.net
🔒 Locked

Multiple source code files in DX project.

Started by GeertPoels 4 replies 200+ views
Original Post
GeertPoels
GeertPoels
hi, I''m working through Lamothe''s "Tricks of the Window ..." and was surprised to find his examples not (barely) to be divided over several source files. Certainly his Outpost game is close to 5000 lines all in one file ... . I would create one ever-to-be-used-again mainfile to setup my DX window and write game logic in separate files. Is it sufficient to just write much-used vars like LPDIRECTDRAW7, LPDIRECTDRAWSURFACE7, ... as externs or are there better ways (reasons to stick with as little files as possible) ? Geert
Ironblayde
Ironblayde
It all gets compiled together anyway, and then you''ll never know if it was one file or thirty... so use whatever''s clear to you. I like to use lots of source files myself...

-Ironblayde
 Aeon Software
"Your superior intellect is no match for our puny weapons!"
GeertPoels
GeertPoels
quote:
Original post by Ironblayde

It all gets compiled together anyway, and then you''ll never know if it was one file or thirty... so use whatever''s clear to you. I like to use lots of source files myself...

-Ironblayde
 Aeon Software


In the beginning, some DX-structs are initialised, how do you make them accessible to all your files ?
Do you uses classes ?
DekuTree64
DekuTree64
Well, I have the same problem, and the only way I''ve found to make it work so far is just pass my LPDIRECTDRAW to a pointer in all of my functions that need it, but it''s kind of a hassle to do.
Anybody else havea solution?

-Deku-chan

"I''m dropping like flies!" - me, playing Super Smash Bros. (and losing)
"What fun!" - me, playing Super Smash Bros. (and beating the crap out of somebody)
Quantum
Quantum
make a header file, and put extern LPDIRECTDRAW lpdd; in there, then include that in the other source files
that way they have access to it
BitMaster
BitMaster
I like it class orientated...
    
// display.h

class CDisplay {
// everything that is display related

};

extern CDisplay Display;

// display.cpp

CDisplay Display;

// implementation of CDisplay




works fine if you like classes

Topic Locked

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

Sign in to reply to this topic.