Jump to content
  • Advertisement
Sign in to follow this  
ajm113

Creating Global Variables For ALL Files. (C++)

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

Ether my brain is shutting down on me for not sleeping right now, but my mind is blank and I did some searching, but I want to create a variable that is defined and is available in each file to change the values for one file to another. Example if I had a bool called talk that I defined in one file and wanted to change the value in different CPP file or header how can I do it for all files?

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by ajm113
Ether my brain is shutting down on me for not sleeping right now


If you are sleep deprived and can't figure something out, it is nearly always correct to sleep and worry about it later.

Quote:
, but my mind is blank and I did some searching, but I want to create a variable that is defined and is available in each file to change the values for one file to another.


Why do you think you want to do this?

Share this post


Link to post
Share on other sites
Thanks, got it going!

@Zahlman
Because I want to disable model rotation to allow the camera to rotate with out the model moving with it.

Share this post


Link to post
Share on other sites
Argh. This is not a good enough reason to warrant globals IMHO. Think about if your code becomes more complex -- you'll sometimes want to look where you declared something and finding globals is such a pain :( (especially if you didn't write the code in the first place).

Just my two cents.

~Shiny

Share this post


Link to post
Share on other sites
Quote:
Original post by ajm113
Thanks, got it going!

@Zahlman
Because I want to disable model rotation to allow the camera to rotate with out the model moving with it.


So, you have one module that represents the model, and offers an interface for rotating it, and another module that decides when/whether to rotate the model (and/or camera), and which can be told "never rotate the model" with a function, not a "published" global variable. Even if it needs a global for the implementation to work, you can put a saner interface on it.

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!