Jump to content
  • Advertisement
Sign in to follow this  

structuring game code

This topic is 2148 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi guys, I'm having a self doubt right now. But first, let me tell you the cause. It's the way I structure my game code. Specifically it's how I put my variables. Basically I have a source code for each module (gfx, sound, input, log). Thing is, I put each variable in their specific .cpp files:


for example, I put screen attributes (and any screen related function definition) in gfx.cpp


//in gfx.cpp

int screen_w, screen_h, screen_bpp;


and I put any screen related function declaration in gfx.h


//in gfx.h


int gfx_create_screen(int w, int h, int bpp);

int gfx_switch_fullscreen(int fs);


I also do the same with the logging module. I put the log function declaration in the log.h, and the definition and logfile handle in log.cpp



-is what I do is right? and uh, if not, can you tell me a better way? I really really appreciate any input here. thanks!

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!