Jump to content

Cross-platform multiplayer game in JavaScript


tips4design
 Share

Recommended Posts

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 onboth clients?


PS2: When I say multiplayer I mean over the internet, not a local ad-hoc multiplayer for mobile devices.


PS3: I will be using Phaser as the framework.


Link to comment
Share on other sites

Bombermine is probably the best multiplayer HTML5 game I've seen. You can see what Ivan wrote about building the backend here: http://www.html5gamedevs.com/topic/2734-creating-a-mulitplayer-game-using-html-5-javascript-and-websockets/?p=18370

 

Not sure I'd recommend Java for this, but it's an option... 

 

A game like Bombermine probably has a little more room for lag than a shooter (but not a ton). 

 

The other option as you mentioned is RTC (WebRTC). Mozilla used it for one of their demo games, Banana Bread: https://hacks.mozilla.org/2013/03/webrtc-data-channels-for-great-multiplayer/

 

Though without verifying moves on a server, cheating is obviously easier.

 

Here's another great article related to multiplayer: https://developer.valvesoftware.com/wiki/Source_Multiplayer_Networking - things like interpolation are incredible important.

Link to comment
Share on other sites

  • 2 weeks later...

Hi!

 

Why don't you try AppWarp. AppWarp is multiplayer game engine and being a cloud service you don't even have to worry about servers. It's also free for Indie Game developers (up to a certain limit). AppWarp has all the features that a multiplayer game might require like Rooms, Lobby, MatchMaking, etc. AppWarp is cross platform and supports a lot of platforms including HTML5. Here is a tutorial for creating multiplayer game/app in HTML5 http://appwarp.shephertz.com/game-development-center/the-chat-app-walkthrough/

 

Thanks

Link to comment
Share on other sites

Hi!

 

Why don't you try AppWarp. AppWarp is multiplayer game engine and being a cloud service you don't even have to worry about servers. It's also free for Indie Game developers (up to a certain limit). AppWarp has all the features that a multiplayer game might require like Rooms, Lobby, MatchMaking, etc. AppWarp is cross platform and supports a lot of platforms including HTML5. Here is a tutorial for creating multiplayer game/app in HTML5 http://appwarp.shephertz.com/game-development-center/the-chat-app-walkthrough/

 

Thanks

 

Thanks for your reply, AppWarp really loks nice but I have already completed by HTML5 game using Phaser. I would simply copy the code to the server side for the Multiplayer, but I was looking for the best way to make the connection and synchronization between clients and server. I think I will end up creating my own functions for it (match-making, packet sending, interpolation etc...), as it might be easier than learning a new framework.

Link to comment
Share on other sites

Thanks for your reply, AppWarp really loks nice but I have already completed by HTML5 game using Phaser. I would simply copy the code to the server side for the Multiplayer, but I was looking for the best way to make the connection and synchronization between clients and server. I think I will end up creating my own functions for it (match-making, packet sending, interpolation etc...), as it might be easier than learning a new framework.

That's ok. But you should check out AppWarp atleast once. It is not restricted to a certain game engine. You can use AppWarp HTML5 SDK with any HTML5 game engine. And it's also easy to get started. Moreover it will cost you less compared to hosting a server yourself. AppWarp also have free plan for Indies.

 

By the way I am part of AppWarp Development team ;-) So you can ask me anytime regarding AppWarp.

And even if you don't want to use AppWarp and write your own server, go head, you can still ask me anything. I will be happy to help you :)

Thanks 

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...