I had made a couple of custom data types up to this point that I used instead of floats. For example, I had a Dimensions struct that worked like a Vector2 but had a “width” and “height” instead of “x” and “y”. I also had a VectorZero Vector2 setup so I didn’t have to keep initializing a new one everytime I needed to reference 0,0.
But when I made the Character class, all this stuff became unavailable. So I copied and pasted them to the character.cpp and now it all works, but I have redundant code. Now I guess I could put those things in their own “utilities” file and just “#include” that, but I’m a bit confused because I thought by putting these structs and variables outside my “main” function in main.cpp, they would be accessible anywhere in my program, including other classes.
Is this because the “#include” lines are at the top before those structs and variables? I think that’s the case. But if so, can I just move those lines down below the “utiltiy” structs and variables that I wanted to be global? Or do they have to be at the top?
Or should I just create the utilities files and then “#include” them in every single file everywhere?
(This may be moot in this specific example because I may not need the custom data types to organize my info anymore now that I have variables connected to a specific class. Instead of “width” or “knight_width” or “knightDims.width”, for example, I now have “knight.width”, a “width” float specific to the Character class instance “knight”)