0
\$\begingroup\$

I've a really quick and maybe dump question and I don't really know how it is handled generaly. I want to make a tile base multiplayer game. Player doesn't teleport from a tile to another but just walks pixel by pixel. So my client position will be two floats based on the actual position of the sprite on the screen. But on the server, should the position of the player be based on the texture as well, or it must be clientPosition/textureSize ?

Imagine a player being on position x:150;y:100 on his screen, and a tile texture size of 32px, should the position of the same player on the server be 150;100 or 4.6875;3.125 ?

Thank you in advance :)

\$\endgroup\$
5
  • \$\begingroup\$ Why would you want to use two different coordinate systems if you can get away with using just one for consistency? Are there any features that break or you don't know how to implement using one coordinate system or the other? \$\endgroup\$
    – DMGregory
    Commented Jan 1, 2019 at 13:55
  • \$\begingroup\$ So in your opinion I should use same coordinate in both server and client ? I was thinking 'is the server aware of the size of the textures used on the client side ?'. \$\endgroup\$ Commented Jan 1, 2019 at 14:48
  • \$\begingroup\$ Who cares if those positions represent texture sizes? The server doesn't need to know anything about textures, it just needs to know "I need to tell the other players that this player is at 126, 63" — they're just numbers. Interpreting them as pixel coordinates is the client's job. Avoiding unnecessary coordinate transformations will give you less surface area for bugs, and make debugging clearer (eg. if you see a value of 0.5, is that half a pixel or half the texture? If you only ever work with one coordinate system, then there's only one possible answer) \$\endgroup\$
    – DMGregory
    Commented Jan 1, 2019 at 15:20
  • \$\begingroup\$ Ok thank you for you enlightenment. One last thing, if 'm using a matrix (e.g 50*50) to manage obstacles and path, how does the server knows that the player that is at position 150;100 on the screen, is at 4;3 on the matrix ? Maybe I miss something obvious but on my single player game I was using a matrix for such a thing, and to know the coordinates of the player on the matrix I divided the positon by the texture size and it worked well, but as the server does not have any informations about textures, I can't use the same system. \$\endgroup\$ Commented Jan 1, 2019 at 15:43
  • 1
    \$\begingroup\$ Then matrix space is the appropriate lingua franca. Use the one coordinate system that is important for your gameplay interactions. Anything else is a display consideration. \$\endgroup\$
    – DMGregory
    Commented Jan 1, 2019 at 15:44

0

You must log in to answer this question.

Browse other questions tagged .