Jump to content

Server Backed Multiplayer


Geoeo
 Share

Recommended Posts

Hi,

 

Im trying to create a server backed multiplayer game with phaser.

That means that two players will engage on a single map.

Both players will be on different machines so some state has to be sent and synchronised via a server (unless there is another way?)

Do any tutorials exists for this kind of stuff?

I'm guessing I would have to write some ajax code in the update() method of the level I am creating. 
 

Anyways, any pointers / tips are welcome :)
 

Thanks,

Marc

Link to comment
Share on other sites

Hi,

 

I am currenty working on a multiplayer game too.

 

On the server side I use Pomelo as gameserver (http://pomelo.netease.com/ - just as KevinnFtw said websockets and node.js).

This article also helped me a lot with the synchronisation of the movement: https://developer.valvesoftware.com/wiki/Source_Multiplayer_Networking

 

What kind of game are you trying to build?

 - Is it turn based?

 - Do you use Physics?

 - Do you worry about cheating?

 - ...

Link to comment
Share on other sites

You could take a look at Node.js and Socket.io they are great for simple multiplayer games and pretty easy to learn.

 

I used this bundle and worked perfectly for my game (up to 4 players), it's a fighting game with fireballs and swords.

 

The problem remaining for us was to trust each player because each player handles his physics and tells to others that he hit someone, so cheat is easy :(

Link to comment
Share on other sites

Thanks a lot guys!

The valve article looks amazing. I will definitely read through it!

To answer a few questions:

The game will be a simple 2 player bumper car game where the players try to hit each other off an arena.
I will probably not use node.js since I'm gonna use the play server. But I will take a look at web sockets.

 

I really wont care about cheating for now. 

 

I hope ill get something done with that set up :)

Thanks,

 

Marc

Link to comment
Share on other sites

So you are using physics!

 

If you dont worry about cheating than maybe physics on the client side is the best solution since your server has to do lesser work :)

You just have to synchronize x, y, rotation and velocity.

 

But on the other side when any of your players has a slow connection or lags the two players start so see different worlds. Player one has a colision that never happened on the screen of Player two. Who is saying the truth? How did you solved that problem titmael?

 

The only solution I found is the serverside physic engine. The valve article describes a similar approach.

Link to comment
Share on other sites

 

But on the other side when any of your players has a slow connection or lags the two players start so see different worlds. Player one has a colision that never happened on the screen of Player two. Who is saying the truth? How did you solved that problem titmael?

 

 

We don't have collision with restitution between player, but we do have overlap between a sword and a player. The player hitting another one with his sword is trusted so when a player is lagging, it's not fair :) We didn't manage this problem. (Just to know the project I'm talking about was a proof of concept so we didn't push hard that kind of probs).

 

We though about a solution : each player tells the server that he found an overlap between him and a sword or between his sword and another player and the server decides (if both tells same thing in a short time, server validates). I don't see any other solution than having physics server-side.

Link to comment
Share on other sites

So you are using physics!

 

If you dont worry about cheating than maybe physics on the client side is the best solution since your server has to do lesser work :)

You just have to synchronize x, y, rotation and velocity.

 

But on the other side when any of your players has a slow connection or lags the two players start so see different worlds. Player one has a colision that never happened on the screen of Player two. Who is saying the truth? How did you solved that problem titmael?

 

The only solution I found is the serverside physic engine. The valve article describes a similar approach.

 

Makes sense. Im gonna keep it really simple first. So client side physics just as you described.

Lets see what happens :P 

Oh yeah, how do you test a 2 or more player game? Just open multiple browser windows?

 

Link to comment
Share on other sites

Yes, I just open a new browser window :). If you use Cookies use two different Browsers. 

Or ask a friend - everyone likes testing games :D

 

Sometimes its a bit strange since not focused tabs seem to have a lower priority - so it looks like it is lagging.

The best test is with two seperate devices.

 

Link to comment
Share on other sites

  • 1 month later...

Ok.

I got this project into an early alpha stage :P

 

Its still inefficient and a lot of re factoring has to be done. BUUUT the core game mechanics work. :D

So, there is a server running with scala/websockets on the play framework (v. 2.1) - https://github.com/geoeo/multiplayer-server
Then there is the client which connects to the server via grunt (so nodejs server) - https://github.com/geoeo/multiplayer/tree/master

I will re factor this, so that the play server runs everything. 

I hope you guys check it out.

Link to comment
Share on other sites

  • 2 years later...
On 4/30/2014 at 5:20 PM, Taleforge said:

I solved this by moving the p2.js from the client to the server. So that the clients just send their commands (move up, left, right, fire etc.) to the server and than the server responds with the resulting new position.

 

p2.js is available as node.js package!

How do you do collision detection with p2.js on server side? I can't find any tutorial for this. I have also tried matter.js but no documentation about server side too. On client side I can see everything is going OK but on server side it is hard to get it right.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...