Skip to main content
added 1 character in body
Source Link
Philipp
  • 123.2k
  • 28
  • 264
  • 345

You have an authoritative server. That server has no screen, so it doesn't make sense to use pixel-measurements in your game mechanics code. So you should make up a coordinate system which works for you. There are countless ways to handle this. The upper left corner of the play area could be 0.0:0.0 while the lower leftright is 1.0:1.0. Or the origin could be in the center with the play area stretching from -1.0:-1.0 to 1.0:1.0. It really doesn't matter that much where you put the origin as long as it seems plausible for you.

When the clients visualize the game, they need to convert the game-coordinates to screen-coordinates. You can that quite elegantly by setting context.scale and context.translate so the visual coordinate system is the same as your logical.

You have an authoritative server. That server has no screen, so it doesn't make sense to use pixel-measurements in your game mechanics code. So you should make up a coordinate system which works for you. There are countless ways to handle this. The upper left corner of the play area could be 0.0:0.0 while the lower left is 1.0:1.0. Or the origin could be in the center with the play area stretching from -1.0:-1.0 to 1.0:1.0. It really doesn't matter that much where you put the origin as long as it seems plausible for you.

When the clients visualize the game, they need to convert the game-coordinates to screen-coordinates. You can that quite elegantly by setting context.scale and context.translate so the visual coordinate system is the same as your logical.

You have an authoritative server. That server has no screen, so it doesn't make sense to use pixel-measurements in your game mechanics code. So you should make up a coordinate system which works for you. There are countless ways to handle this. The upper left corner of the play area could be 0.0:0.0 while the lower right is 1.0:1.0. Or the origin could be in the center with the play area stretching from -1.0:-1.0 to 1.0:1.0. It really doesn't matter that much where you put the origin as long as it seems plausible for you.

When the clients visualize the game, they need to convert the game-coordinates to screen-coordinates. You can that quite elegantly by setting context.scale and context.translate so the visual coordinate system is the same as your logical.

Source Link
Philipp
  • 123.2k
  • 28
  • 264
  • 345

You have an authoritative server. That server has no screen, so it doesn't make sense to use pixel-measurements in your game mechanics code. So you should make up a coordinate system which works for you. There are countless ways to handle this. The upper left corner of the play area could be 0.0:0.0 while the lower left is 1.0:1.0. Or the origin could be in the center with the play area stretching from -1.0:-1.0 to 1.0:1.0. It really doesn't matter that much where you put the origin as long as it seems plausible for you.

When the clients visualize the game, they need to convert the game-coordinates to screen-coordinates. You can that quite elegantly by setting context.scale and context.translate so the visual coordinate system is the same as your logical.