I have a few specific places in my code where I use specific pixel dimensions to blit certain things to the screen. Obviously these are placed in well named constants, but I’m worried that it’s still kind of vague.
Example: This is in a small function’s local scope, so I would hope it’s obvious that the constant’s name applies to what the method name refers to.
const int X_COORD = 430.0;
const int Y_COORD = 458.0;
ApplySurface( X_COORD, Y_COORD, .... );
...
The location on the screen was calculated specifically for that spot. I almost feel as if I should be making constants that say SCREEN_BOTTOM_RIGHT so I could do like something like const int X_COORD = SCREEN_BOTTOM_RIGHT - SOME_OTHER_NAME.
Is the code above too ambiguous? Or as a developer would you see that and say, alright, thats (430, 458) on the screen. Got it.
Depends. Is there a particular reason those constants are what they are? (For instance, is that “430” actually 200 pixels to the left of some other element?)
If so, then it’d probably make more sense to express it in terms of the constant used for the other element (or whatever reason results in that number).
If they’re all just arbitrary positions, then expressing them as coordinates makes sense. But chances are, they’re not actually arbitrary.