Geoeo Posted April 29, 2014 Share Posted April 29, 2014 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 More sharing options...
KevinnFtw Posted April 29, 2014 Share Posted April 29, 2014 You could take a look at Node.js and Socket.io they are great for simple multiplayer games and pretty easy to learn. Link to comment Share on other sites More sharing options...
Taleforge Posted April 30, 2014 Share Posted April 30, 2014 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 More sharing options...
titmael Posted April 30, 2014 Share Posted April 30, 2014 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 More sharing options...
Taleforge Posted April 30, 2014 Share Posted April 30, 2014 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! titmael 1 Link to comment Share on other sites More sharing options...
titmael Posted April 30, 2014 Share Posted April 30, 2014 That's a very nice news for me. But we used Arcade for the game. Just keep the idea for the next multiplayer game Link to comment Share on other sites More sharing options...
Geoeo Posted April 30, 2014 Author Share Posted April 30, 2014 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 More sharing options...
Taleforge Posted April 30, 2014 Share Posted April 30, 2014 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 More sharing options...
titmael Posted April 30, 2014 Share Posted April 30, 2014 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 More sharing options...
Geoeo Posted April 30, 2014 Author Share Posted April 30, 2014 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 Oh yeah, how do you test a 2 or more player game? Just open multiple browser windows? Link to comment Share on other sites More sharing options...
Taleforge Posted May 1, 2014 Share Posted May 1, 2014 Yes, I just open a new browser window . If you use Cookies use two different Browsers. Or ask a friend - everyone likes testing games 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 More sharing options...
Zaidar Posted May 1, 2014 Share Posted May 1, 2014 I just skimmed a little the topic to reference this source : http://www.gabrielgambetta.com/fast_paced_multiplayer.html It's a very good serie on how to make networking in games. It's focused on fast paced games, but I think you might get some info from there. I found it more "readable" than the valve article. Link to comment Share on other sites More sharing options...
Geoeo Posted June 10, 2014 Author Share Posted June 10, 2014 Ok.I got this project into an early alpha stage Its still inefficient and a lot of re factoring has to be done. BUUUT the core game mechanics work. So, there is a server running with scala/websockets on the play framework (v. 2.1) - https://github.com/geoeo/multiplayer-serverThen there is the client which connects to the server via grunt (so nodejs server) - https://github.com/geoeo/multiplayer/tree/masterI 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 More sharing options...
caymanbruce Posted March 31, 2017 Share Posted March 31, 2017 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 More sharing options...
Recommended Posts