3
\$\begingroup\$

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?

\$\endgroup\$
7
  • 1
    \$\begingroup\$ You may want to read up on this: gamedev.stackexchange.com/questions/48832/… \$\endgroup\$
    – House
    Commented Jun 21, 2013 at 17:08
  • \$\begingroup\$ That won't cover for my type of game. \$\endgroup\$
    – Romeo
    Commented Jun 21, 2013 at 17:09
  • 1
    \$\begingroup\$ 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. \$\endgroup\$
    – Katana314
    Commented Jun 21, 2013 at 17:12
  • \$\begingroup\$ 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? \$\endgroup\$
    – Romeo
    Commented Jun 21, 2013 at 17:15
  • \$\begingroup\$ 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. \$\endgroup\$
    – House
    Commented Jun 21, 2013 at 17:19

1 Answer 1

2
\$\begingroup\$

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.

\$\endgroup\$
1
  • \$\begingroup\$ Should i use a Thread for every game (every 2 plyaers)? \$\endgroup\$
    – Romeo
    Commented Jun 22, 2013 at 12:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .