Skip to main content
grammar and punctuation; removed blacklisted engine tag
Source Link
Gnemlock
  • 5.3k
  • 5
  • 28
  • 59

Creating When creating a Game Engine: How to position game engine, how should I define the position of objects (top left vs. center)?

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 to be atas the top left position.

Or shouldPerhaps I should define it to be the center of the object, which seems to make more sense, logically? If we use width/2width/2 and height/2height/2 to calculate it, does the slightly truncated-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.

Creating a Game Engine: How to position game objects (top left vs. center)

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 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 to be at the top left.

Or should I 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.

When creating a game engine, how should I define the position of objects?

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.

Tweeted twitter.com/StackGameDev/status/663556005679276032
Source Link

Creating a Game Engine: How to position game objects (top left vs. center)

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 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 to be at the top left.

Or should I 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.