flockonus Posted March 22, 2015 Share Posted March 22, 2015 I have some overly ambitious idea that I'm cannot promise i'll actually fully get to it, but the overall concept is the following: I'd like to create an online game, that is real time, and has physics elements, i'd like to build it in Phaser and have instances synchronizing, including the state of physics across the clients and server. To make it happen, we have to account for random lag, in the the physics library, as well as the rendering would have to accommodate for facts that will be updated in the past (from the local client perspetive). Minor but might be important: the priority is to be consistent and not competitive (MMO case), so I'd be ok with some level of "cheating" if it even matter. I'd be implementing the server in Node.js, but didn't find any robust example online of it, not much of a surprise actually, feels like a rather complex use case. If it's still not clear the challenge, imagine the following scenario: 0:00:00 2 players are connected in a session0:00:01 player 1 fire a bullet, he/she sees it happening on their screen as makes sense0:00:02 the action gets to the server0:00:03 player 2 receives the shoot info, and sees the shot happening at the position 00:00:03 just like it is for player 1 Would be extra nice to have fast forward the action that happen in the past until the moment that reaches 'present' state All that said; is there a phys lib that allow to set events happening in the past? Already assuming not, is there a recommended path to implement so? I'm no physics wizard. edit: To make a decent MMO the server should execute the very same state as the clients (minus the rendering) in order to validate inputs and sync clients Thanks in advance! Link to comment Share on other sites More sharing options...
trueicecold Posted March 22, 2015 Share Posted March 22, 2015 Actually, traditional MMO games don't execute commands on the sender side before it reaches the server. For all concerns, the sender is also a receiver, and should act like one. The bullet shouldn't be fired on the sender side, without receving a command to fire it from the server, just like other players should. Link to comment Share on other sites More sharing options...
flockonus Posted March 22, 2015 Author Share Posted March 22, 2015 Thanks @trueicecold, I realize how what you are saying is right, and makes sense, and would actually make my life easier. But for this case, aiming + shooting on moving targets would be a fundamental component of this game, and to produce the experience intended, the requirements are not usual but these elements must be there Link to comment Share on other sites More sharing options...
MichaelD Posted March 22, 2015 Share Posted March 22, 2015 I would suggest using Socket.io so that the game feels more real-time (sockets can accomodate this). I had created a tanks game in the past with this scenario you describe, and it worked like this. Server is in Node.js and has the ability to open a "room" when 2 players connect via sockets (a roomID is produced and all following calls need this id to know where to route each command)With sockets you can send a broadcast command or a specific command to a single entity (connected client). This is essential as the broadcast is needed to alert all clients that they need to update their positions/health, but the specific command is needed to "tell" a specific client that he needs to shoot a bullet (or not, it depends on the implementation) So in the server side you make an API with fuctions like move(roomID, clientID, options)So when an entity in the game wants to move it calls the move function to alert each other entity (in different clients) that this guy moved, then each client receives an event like onSomethingMoved and updates the view. Basically with socket.io you do exactly that, define events that are responses from the server and update the client accordingly. Link to comment Share on other sites More sharing options...
flockonus Posted March 22, 2015 Author Share Posted March 22, 2015 Thanks @MichaelD On network level my plan is quite similar indeed, i'll probably try first https://github.com/websockets/ws hoping for a slightly better speed and control over disconnect. My question is more about the path on Phaser and the physics libraries, is there one that's more fit and I could run it server-side, or should I consider implementing my own? Link to comment Share on other sites More sharing options...
Recommended Posts