I am creating a multiplayer HTML game which focuses on manipulating planet trajectories with gravity points. I am creating bunch of planets with random initial velocity and random direction and i am sharing info about this planets to a server. Though i am keeping track of every planets position on server, i am not sharing this values every second to each player. My idea is that if i only share planets position whenever a new player joins then from that point onward clients should be able to calculate new position of planet every second because directions and speed of the planets will be same for all players. This idea works for screens with same resolutions and aspect ratio but it fails for other cases.

can anyone suggest other idea for keeping track of planets position for screen with resolutions?

This game is multiplayer so i need something that will allow me to provide same scene to every player.

  • \$\begingroup\$ Where does screen resolution factor into your calculations of game world positions? Normally we keep game world position distinct from display position, so we separate the problem of simulating the game state from the problem of displaying a view of that state. \$\endgroup\$
    – DMGregory
    Commented Sep 6, 2019 at 16:44
  • \$\begingroup\$ i forgot to mention that it is a 2d game and i am calculating y and x vector of speed according to gravity force and simply adding them to x and y coordinate of planets.so you can see that for different resolution there would be some change in position of planets. \$\endgroup\$ Commented Sep 6, 2019 at 16:50
  • \$\begingroup\$ This is what DMGregory is trying to hint you. Positions, directions, speeds, etc should be in "world units", and the world units should be converted to screen x, y once they need to be displayed. The logic of your game should not rely on the size of a screen. \$\endgroup\$
    – Vaillancourt
    Commented Sep 6, 2019 at 19:41
  • \$\begingroup\$ Can you provide some link or article that explains the conversation between world coordinate and screen coordinate? \$\endgroup\$ Commented Sep 7, 2019 at 4:30


You must log in to answer this question.

Browse other questions tagged .