Oyed Posted November 3, 2015 Share Posted November 3, 2015 This is something I've been thinking about for a while and I was wondering if anyone could help, or had some input. All of the Canvas multiplayer Socket.IO/Websocket tutorials I've seen on the web, including BrowserQuest, handle game logic locally and then send it to the server to broadcast to connected parties. This allows people, with little knowledge of JavaScript, to cheat really easily. My question is; what is the best way to overcome this? I've tried a couple things before, for example sending key presses to the server and handling logic, then broadcasting to connected parties, but it can easily lag behind with a few people online. Quote Link to comment Share on other sites More sharing options...
WombatTurkey Posted November 3, 2015 Share Posted November 3, 2015 Send the players positions, x, y (and z, if it's a 3d game) to nodejs. Process that request inside node, check for the distance to prevent a player from teleporting all around the map, then pipe that data to all other players in the game to notify where the player went. It won't lag, unless maybe you have someone that lives half a world away, but in that case, create a server in that location and direct those players to that server. Think of Diablo 2 (UsWest, UsEast, Asia, Europe) and use Redis for pub sub. If you're working with node, I highly recommend Pub Sub with Redis (http://goldfirestudios.com/blog/136/Horizontally-Scaling-Node.js-and-WebSockets-with-Redis) as if you want a massive mmorpg game, you will need to utilize more than one nodejs v8 isolate (1 core). And use a front end proxy like nginx or haproxy Quote Link to comment Share on other sites More sharing options...
Oyed Posted November 3, 2015 Author Share Posted November 3, 2015 Send the players positions, x, y (and z, if it's a 3d game) to nodejs. Process that request inside node, check for the distance to prevent a player from teleporting all around the map, then pipe that data to all other players in the game to notify where the player went. It won't lag, unless maybe you have someone that lives half a world away, but in that case, create a server in that location and direct those players to that server. Think of Diablo 2 (UsWest, UsEast, Asia, Europe) and use Redis for pub sub. So continue to process game logic client-side, but have checks in place server-side? Quote Link to comment Share on other sites More sharing options...
WombatTurkey Posted November 3, 2015 Share Posted November 3, 2015 So continue to process game logic client-side, but have checks in place server-side? Yeah, if you using a point to click method (like diablo 2) once that player clicks move that player on the client instantly so there is no 'lag', but secretly send the x,y positions to the server to then notify all other players. That's the beauty with websockets. And those other players will be notified almost instantaneously. Quote Link to comment Share on other sites More sharing options...
Oyed Posted November 3, 2015 Author Share Posted November 3, 2015 Yeah, if you using a point to click method (like diablo 2) once that player clicks move that player on the client instantly so there is no lag, but secretly send the x,y positions over to notify all other players. That's the beauty with websockets. It's a top-down game, however movement isn't point-to-click, nor is it restrained to a grid, it's free Left-Right-Up-Down movement Quote Link to comment Share on other sites More sharing options...
WombatTurkey Posted November 3, 2015 Share Posted November 3, 2015 It's a top-down game, however movement isn't point-to-click, nor is it restrained to a grid, it's free Left-Right-Up-Down movement Like WASD movement? Quote Link to comment Share on other sites More sharing options...
Oyed Posted November 3, 2015 Author Share Posted November 3, 2015 Like WASD movement? Exactly Quote Link to comment Share on other sites More sharing options...
WombatTurkey Posted November 3, 2015 Share Posted November 3, 2015 Exactly Okay, well then each time a player presses W, A, S, or D do the same thing. Move the character clientside and send the data over so all other players know where that player moved to. Same thing really Is that what you're curious about? Quote Link to comment Share on other sites More sharing options...
webcaetano Posted November 3, 2015 Share Posted November 3, 2015 A good option is make an isometric game. And you just need to parse the cell in socket.io.not the x and y. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.