I'm building a custom game engine, in C++ using SDL, and I'm not sure how I should define the position of my game objects. I tried googling a bit, but I wasn't sure how to refine my search terms to get what I'm looking for.
Should I define the position (x, y) of my object to be the top left of the object, for ease of rendering? Since my game is tile based, it also makes sense to have the position of the tiles as the top left position.
Perhaps I should define it to be the center of the object, which seems to make more sense, logically? If we use width/2
and height/2
to calculate it, does the slightly-truncated integer for even-sized objects matter?
How do other games do this? Right now, my objects are defined by the top left corner, and it's annoying to do operations that find the center of the object.