1
votes

I'm working on a toy game engine. I have never been thinking about coordinate system, just accepted them as is, but now I'm a bit confused.

So, this is how common game coordinate system looks like (most Canvas implementation use top-left corner as (0,0), and Y axis goes down):

Normal coordinates

For sprites, it would be natural to accept top-left corner as sprite position.

Now let's see how rotation happens. If in common coordinate system Y axis goes up, the rotation is CCW if the angle is positive. And, the angle of zero is pointing to the right. If Y axis goes down, then the rotation is CW:

angles

From this I can assume that all sprites are drawn rotated by 90 degrees by default? Am I correct? Or should I draw them flipped and rotate -90 degrees? Or should I assume them the angle of 0 is pointing down instead of right (which seems to be incorrect to me).

sprites rotated

What coordinate system is recommended to use in game engines? And, actually, what is preferred - measuring in degrees or radians?

Thanks, Serge.

1

1 Answers

1
votes

You shouldn't assume all sprites are rotated & flipped. You should use programming codes in your game engine to fit your needs.

For the choice of coordinate system, I will pick anchor point at sprite's center when I'm working on top-down perspective games; I will pick anchor point at sprite's left top corner when I'm working on horizontal scroller games (like Mario). Of course, for 3D world, it's different story. It depends on how your sprites move. Anchor point should be placed at a position that does not move frequently.