Jump to content

  • Log In with Google      Sign In   
  • Create Account


Sharing display dimensions between source files - C++/Allegro


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 Ben Dixon   Members   -  Reputation: 176

Like
0Likes
Like

Posted 04 September 2012 - 07:44 PM

Ok, so I'm trying to make a simple game, and instead of hardcoding my starting values for the player's image location, I want to calculate the position based on display size. My problem is that in my player's implementation file, the Allegro display is not defined. I also can't find a way to get a const to span object files (since I'm compiling each .h/.cpp combination into a .o and then combining the .o files). And the #define directive does not span object files either. Am I going about it the wrong way, or am I going to have to just define the SCREEN_W and SCREEN_H variables in each header?

Edited by swiftcoder, 04 September 2012 - 07:58 PM.


Sponsor:

#2 swiftcoder   Senior Moderators   -  Reputation: 9856

Like
0Likes
Like

Posted 04 September 2012 - 08:00 PM

We prefer that you post the solution to your problem, rather than deleting your post.

It seems to me that you should declare the const variables in one header file, implemented them in the matching .cpp file, and import the headed in each other header file.

Tristam MacDonald - Software Engineer @Amazon - [swiftcoding]


#3 Ben Dixon   Members   -  Reputation: 176

Like
0Likes
Like

Posted 08 September 2012 - 02:38 PM

I didn't realize that I needed to extern the variables in all the files, but define them only in the main source. Thanks for the suggestion.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS