I want to start creating a simple multiplayer, JavaScript based, cross-platform game. Think about it as a two player mario where players can shoot each other.
My question is what is the best way (or at least a feasible way) to implement multiplayer into the game. I was thinking about:
- Running the game on the both clients, from which one of them is considered to be the server and the other is playing catch-up.
- Using my web server only to establish the connection between the two clients (and forward requests between them, I think this is easier then trying to use some RTC peer-to-peer protocol).
I have never done any multiplayer game, so I do not know if this method is good. One flaw in the design is that the game becomes very hackable (as the one that is considered to be the server has control over all the legal move validations done).
So, my question is if, using this method, a playable multiplayer game can be implemented, where if one player clicks the "shoot" button pointing in a specific direction the other player would receive this data in a period of time short enough so that he can react to it. If not, what is another reliable way to create a JavaScript
, cross-platform (web, mobile) game?
If I were to also run an instance of the game on the server for each duel betwen two clients I think the servers would be over-loaded very easily, so I don't consider this a solution.
PS: About the hackable part. Do you think it can be reduced if I can somehow implement checkings on both clients?
PS2: When I say multiplayer
I mean over the internet, not a local ad-hoc multiplayer for mobile devices.