How to solve problems with movement in simple tile based multiplayer game?

Posted by Murlo on Game Development See other posts from Game Development or by Murlo
Published on 2014-06-04T13:14:37Z Indexed on 2014/06/04 15:46 UTC
Read the original article Hit count: 261

I'm making a simple tile based 2D multiplayer game in JavaScript using socket.io where you can move one tile every 200 ms. The two solutions I've tried are as follows:

  • The client sends "walk one tile north" every 200 ms. Problem: People can easily hack the client to send the action more often.

  • The client sends "walking north" and "stopped walking". Problem: Sometimes the player moves extra steps when "stopped walking" doesn't arrive in time.

Do you know a way around these problems or is there a better way to do it?

EDIT: Regarding the first solution I've tried adding validation on the server to check if it has been 200 ms since last movement. The problem is that latency still encourages people just to spam the action as much as possible, giving them an unfair advantage.

© Game Development or respective owner

Related posts about 2d

Related posts about JavaScript