3

I am working on 2-player 2d sidescroller.

How should I implement the physics on the server? Use one world for every game or use a big world in which I add every 2 player that start a game?

I have looked into some source code of multiplayer games and I saw that they don't implement any kind of game loop on the server, instead they work with events. If the game has physics handled by the server shouldn't the server use a game loop to call the step method?

John McDonald
  • 6,746
  • 2
  • 31
  • 45
Romeo
  • 481
  • 6
  • 16
  • 1
    You may want to read up on this: http://gamedev.stackexchange.com/questions/48832/run-a-physics-simulation-on-both-client-and-server – House Jun 21 '13 at 17:08
  • That won't cover for my type of game. – Romeo Jun 21 '13 at 17:09
  • 1
    I understand you might not use Box2D, but what seems so different about that answer? There's a lot of ideas there on what sort of things you'd need to cover in that scenario. – Katana314 Jun 21 '13 at 17:12
  • It explains that for every 2 players a game is started on the server. @Katana314 : I use Box2D but he has a world for the entire game objects while i will have multiple game instances on my server. I want to know if it's better to use one world per instance. Also i deserve a votedown for insisting of keeping the image? – Romeo Jun 21 '13 at 17:15
  • The physics of one instance shouldn't affect any other right? That would mean one world per instance. Can you clarify the question? "How should I implement the physics on the server" is a very broad question. – House Jun 21 '13 at 17:19
  • Box2D has the ability to stop certain objects from interacting with others. – Romeo Jun 21 '13 at 17:26
  • I have added information from Romeo's latest question, and I agree with Byte56, the image doesn't add anything to the question. – John McDonald Jun 22 '13 at 01:20

1 Answers1

2

How should I implement the physics on the server?

As per rasmuses answer to a similar question, you want to run the physics simulation on both the client and server. If the physics does not run on the client, then it will look very choppy. And if the physics does not run on the server, then clients could get out of sync.

Use one world for every game or use a big world in which I add every 2 player that start a game?

You also mention in the comments: Box2D has the ability to stop certain objects from interacting with others. I think running a single Box2D simulation on the server would cause more issues than it would solve. It would be best to run one Box2D simulation per game.

John McDonald
  • 6,746
  • 2
  • 31
  • 45