Jump to content
  • Advertisement
Sign in to follow this  
ryan mccabe

Including, not including, dependencies ect.

This topic is 2706 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

I'll admit at the moment Im fully confused by file dependencies. Right now I'm working with a system Ive inherited from a tutorial where everything is in a class and each class is a file. System is at the top with input graphics camera ect going to system. Works fine in the tutorial, but Ive left the tutorial and started coding in what I want. Got a keyboard setup with windows msgs, the tutorial left me with windows msgs in system and input reading from it. Ive hooked input from system into input then out to graphics to the update camera position. Each frame input gets keys pressed and graphics gets the data from there to apply to the camera position before rendering. I ran into trouble when I decided the mouse was going to be a structure holding relevant key presses old and new position data to compare how much movement has occurred between frames and whatever else. I thought this would be a lot tidier than passing a mess of variables, and less confusing to read than the array I set to hold WASD keys. Trouble was the mouse structure was being recognized in graphics or input. . . well the syntax highlighting and error checking inside VS2010 said it was good but the compiler complained and then blew up about a host of unrelated issues.

I'm sure I could make it work but after trying it Ive had the notion that the overall structure is potentially quite messy while conceptually clean. Passing windows messages from system to input to wherever the input actually does something is a lot of data to pass every single frame. So what to do?

Is there a generally preferred structure to game dependencies at the very basic level? Is having classes that encompass each file a good way to go, I realize that in oop everything is an object and thus a potential class but is having each class be a file just killing my compile time and complicating life in general? What are some general guidelines on file structure, dependencies, and passing data between files?

I hope Im not too vague or long winded and thanks for replies.

Share this post

Link to post
Share on other sites
First of all: Do not try to write HUGE game (or any other app) at the very begining. It just won't work.
Try something simple first. Tetris, text game with graphical interface or something like this.
If You experience problems like name collision just change the name of Your class.

I can recommend this book.
There is little about every issue You have mentioned to have trouble with.

Make simple classes for every task You'll need and test them in separate programs.
After You test them troughly, You can join them in one big program.

I am not sure if I have understood Your question correctly but:
It is required to have each class in separate file. In header file You put a definition of a class
and in source file You put the code snippets :)


Share this post

Link to post
Share on other sites
I'm working on a basic 3d set up right now as a base to test components. Ive worked through a ton of console games, some sdl games and have now started with directx which has added a lot of complexity. Anyway its not really even a game right now. Its good to know that each file should be a class, thanks :)

Edit: If I have File A at the root including File B and File C, can File D be included in both File B and File C?

Share this post

Link to post
Share on other sites
II'm guessing c++? If so you may notice that each header file has either #pragma once at the top or inclusion guards

#ifndef _FILENAME_H_
#define _FILENAME_H_
// file content

This allows file B and C to both include D and file A to include B and C which in turns includes D. It ensure the entire unit only ever has one copy of each, if you didn't use inclusiotn guards/pragma once then you will run into problems. Sometimes you may not even need to include file D in a header (only in a cpp file), take a look at forward declarations, it helps reduce dependancies among your files.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!