Biggerplay Posted February 16, 2013 Share Posted February 16, 2013 I'm thinking of doing a html5 multiplayer game and I'm researching the options for that. Does anyone have any suggestions for the best way to go in regards to server API's etc? I'm aware of parse.com and pusher.com Are there any particular issues to be aware of when dealing with multiplayer games and JS? Regarding the front end, are any particular libraries better suited to multiplayer than others?Thanks for any advice. Quote Link to comment Share on other sites More sharing options...
endel Posted February 16, 2013 Share Posted February 16, 2013 Meteor looks gorgeous for games. I suggest you to give a try. The famous Mozilla game called BrowserQuest uses node.js / websockets, and it's open-source. Quote Link to comment Share on other sites More sharing options...
Biggerplay Posted February 16, 2013 Author Share Posted February 16, 2013 Meteor looks gorgeous for games. I suggest you to give a try. The famous Mozilla game called BrowserQuest uses node.js / websockets, and it's open-source.Meteor looks interesting I'll definitely look into that. I'm new to JS though so I'm wondering if I need something more game specific though. Quote Link to comment Share on other sites More sharing options...
gin5eng Posted February 16, 2013 Share Posted February 16, 2013 Meteor looks gorgeous for games. I suggest you to give a try. The famous Mozilla game called BrowserQuest uses node.js / websockets, and it's open-source. Meteor looks great for building websites and games that don't depend on having low latency. But if your goal is to build a game where 10-20 or maybe even hundreds of players are all playing simultaneously, you're probably going to end up at another solution. So I recommend just straight up NodeJS and Websockets. Here is a good read about some of the invisible issues caused by high latency that most games hide very well. http://gafferongames.com/networking-for-game-programmers/what-every-programmer-needs-to-know-about-game-networking/ Very good articles about general game network programming IMO:http://www.gameproducer.net/2006/12/16/planning-is-essential-in-writing-multiplayer-network-code/ Quote Link to comment Share on other sites More sharing options...
Biggerplay Posted February 17, 2013 Author Share Posted February 17, 2013 Meteor looks great for building websites and games that don't depend on having low latency. But if your goal is to build a game where 10-20 or maybe even hundreds of players are all playing simultaneously, you're probably going to end up at another solution. So I recommend just straight up NodeJS and Websockets. Here is a good read about some of the invisible issues caused by high latency that most games hide very well. http://gafferongames.com/networking-for-game-programmers/what-every-programmer-needs-to-know-about-game-networking/ Very good articles about general game network programming IMO:http://www.gameproducer.net/2006/12/16/planning-is-essential-in-writing-multiplayer-network-code/So that just applies to real time multiplayer, what about turn based? or even basing the game on rooms (lobbies) so you limit the number of people in a room, even though overall there might be many rooms being used. Quote Link to comment Share on other sites More sharing options...
mouseluka Posted February 19, 2013 Share Posted February 19, 2013 I try to make a turn-based(with server-side timer of turn) game on node.js and websockets. It really is not that hard. By the end of the week will create a theme from Showcase Quote Link to comment Share on other sites More sharing options...
ianballantyne Posted February 19, 2013 Share Posted February 19, 2013 Being aware of latency and taking that into account in the design of your multiplayer component of a game is quite important. Since websockets work over TCP, poor quality of service results in bursts of information. You can have a relatively consistent stream of information for a while and periodically get spikes in latency followed by a flood of messages. This will mainly affect real-time multiplayer games. While we were working on Score Rush Multiplayer (4-player bullet hell shooter) we spent a lot of time making sure that these spikes in latency affected the player's experience as little as possible.We added a few bits of advice to the game development tips section of our documentation If you're interested here is our real-time multiplayer API, which is a session based, client-to-client interface that uses websockets and quick relay server.We also have a turn-based API in the works, which it sounds like something you would be more interested in. Quote Link to comment Share on other sites More sharing options...
threebeans Posted February 19, 2013 Share Posted February 19, 2013 I have been thinking about trying the new https://github.com/peers/peerjs library and doing some peer-to-peer style multiplayer. Looking at their documentation it looks pretty simple, but I have also not actually tried it yet. Quote Link to comment Share on other sites More sharing options...
andrewjbaker Posted February 19, 2013 Share Posted February 19, 2013 Check out the multiplayer articles on Build New Games... http://buildnewgames.com/blog/categories/multiplayer/ Quote Link to comment Share on other sites More sharing options...
Autarc Posted February 19, 2013 Share Posted February 19, 2013 I would recomend to use the more popular "Client-Server" architecture, at least your first time. Either using native WebSockets or a Library which provides fallbacks eases the setup on your own server. In addition, if you like to use Node.js - you could share some Code for the calculations/predictions You can find here an overview + example: http://www.wildbunny.co.uk/blog/2012/10/09/how-to-make-a-multi-player-game-part-1/ The Problem with the "Peer-To-Peer" approach is the data handling and usability right now. As the entire game will run on the client side, it's difficult to prevent abusage and cheating. As currently no stable browser supports DataChannels, it's also unlikely to be played by common websters. If you are interested what holds up the future: I am working on a P2P Gaming Framework called PeerGaming for my graduation.My research is almost done, so I should be able to start with the implementation soon Quote Link to comment Share on other sites More sharing options...
oberhamsi Posted February 20, 2013 Share Posted February 20, 2013 if you plan on doing a real-time multiplayer, take a look at how http://banditracer.eu/ does it. Domas - the author - ported Vavle's network prediction & lag compensation and it workes quiet well (not for dozens of users but good enough for 4 racers). edit: the Valve wiki has an excellent explanation of interpolation, etc <https://developer.valvesoftware.com/wiki/Source_Multiplayer_Networking> Quote Link to comment Share on other sites More sharing options...
gin5eng Posted February 20, 2013 Share Posted February 20, 2013 So that just applies to real time multiplayer, what about turn based? or even basing the game on rooms (lobbies) so you limit the number of people in a room, even though overall there might be many rooms being used. Meteor is probably ok for turn based. But it's scope is limited. I would just learn and implement with node.js/socket.io so if you want to move onto something other than turnbased later, you already know how to use node.js and socket.io. Quote Link to comment Share on other sites More sharing options...
hima Posted February 23, 2013 Share Posted February 23, 2013 A lot of useful information here. I've been thinking of making a simple online or multiplayer HTML5 game just to learn how it works. I'll take a look at node.js and socket.io :-) Quote Link to comment Share on other sites More sharing options...
Quetzacotl Posted February 27, 2013 Share Posted February 27, 2013 I don't recommend node.js if you care about speed. Javascript is a bad choice for backend and async model used in node.js is one of the worst. http://news.ycombinator.com/item?id=4495101 Quote Link to comment Share on other sites More sharing options...
mouseluka Posted February 27, 2013 Share Posted February 27, 2013 My first try in node.js multiplayer: game crystals Quote Link to comment Share on other sites More sharing options...
Ezelia Posted February 27, 2013 Share Posted February 27, 2013 @Quetzacotl your argument was maybe true some years ago V8engine and Nodejs with it's support to both native and JS extensions changed things.and if we are speaking about network speed, JS, C# or C++ code has nothing to do with that, network latency will be allways the same if you use TCP (I'm not speaking about UDP here nor about some specific protocols witch add overhead to network requests ) Quote Link to comment Share on other sites More sharing options...
Quetzacotl Posted February 27, 2013 Share Posted February 27, 2013 @Quetzacotl your argument was maybe true some years ago V8engine and Nodejs with it's support to both native and JS extensions changed things.and if we are speaking about network speed, JS, C# or C++ code has nothing to do with that, network latency will be allways the same if you use TCP (I'm not speaking about UDP here nor about some specific protocols witch add overhead to network requests )Obviosly I'm not talking about network speed and I don't know why you would think otherwise. Javascript wasn't designed to work as a server backend, there are many better alternatives for this purpose. node.js can be a way to go if you don't know other lanugages and you don't plan to scale app much, since node.js is hard to scale (I don't say it's impossible, it's just much harder). I have to quote this Node.js does help you to fail fast Quote Link to comment Share on other sites More sharing options...
Autarc Posted February 27, 2013 Share Posted February 27, 2013 Javascript wasn't designed to work as a server backend, Not true at all - besides the latest node effort, it was almost 20 years ago used for this purpose: https://en.wikipedia.org/wiki/Server-side_JavaScript#Server-side_JavaScript The good part of using a Node.js backend for gaming, is the simplicity and community support. In case you want to do realtime communication, you can just leverage the complex part and use a WebSocket library via npm. Many people here could probably help you with the setup etc. Other environments are great as well - but as you will probably use JavaScript on the client side, so you get the chance to re-use some code or at least exercise your scripting skills Quote Link to comment Share on other sites More sharing options...
Quetzacotl Posted February 28, 2013 Share Posted February 28, 2013 I think you misunderstood. I said js wasn't designed for backend, not that it wasn't used there. It was originally implemented as part of web browsers so that client-side scripts may interact with the user, control the browser, communicate asynchronously and alter the document content that is displayed.You know that javascript was designed in about 10 days? It says everything about it. I tried node.js, as well I wrote my own TCP server with Python, I also wrote my own websocket library. RIght now I'm developing app using Twisted and it's much, much easier to maintain and develop, and still it's faster. It's not node.js fault, it's javascript fault. I know that ppl now are hyped about it for no real reason, except that you don't have to know any other language than js. Quote Link to comment Share on other sites More sharing options...
EmployeeNumber8 Posted March 1, 2013 Share Posted March 1, 2013 node.js can be a way to go if you don't know other lanugages and you don't plan to scale app much, since node.js is hard to scale (I don't say it's impossible, it's just much harder). Define "harder to scale". I've found it quite easy to scale. When you talk about what the language was designed for, and the async model - those arguments are purely academic... but in the real world, companies like eBay, 37signals, Cloud9, Yahoo!, LinkedIn, Flickr, Microsoft , Twitter (on a small scale), Instagram (I think)... are all using nodejs on the server side. These are companies that really have to deal with massive scaling. By your own admission, you've only "tried" it. Show some real world examples of how/why nodejs is a poor choice for scaling. Projects, applications, companies using nodejs Quote Link to comment Share on other sites More sharing options...
Felipe Posted March 3, 2013 Share Posted March 3, 2013 I've made a small chat using html5 for client and as3 for a simple server. It could be useful for testing.https://github.com/ilovepixel/HTML5ChatDemo Quote Link to comment Share on other sites More sharing options...
ZippoLag Posted March 19, 2013 Share Posted March 19, 2013 Well, I'm currently diving into WebRTC, I found this lengthy article on html5 rocks that sums it up pretty much: http://www.html5rocks.com/en/tutorials/webrtc/basics/ If I'm not mistaken, it has a component (RTCPeerConnection or rather DataChannel?) that should pretty much allow you to implement UDP-like connections, wich we all know is mandatory for real time multiplayer games. It's not even listed on caniuse for some reason, but it seems to be widely supported by firefox and chrome now, althought with prefixes. I haven't had the time to whip-up a demo, but if anyone's interested my job here'll be done. Quote Link to comment Share on other sites More sharing options...
Autarc Posted March 20, 2013 Share Posted March 20, 2013 @ZippoLag: Unfortunately it's quite the opposite: most browsers doesn't have it implemented yet - especially for accessing it directly. To send arbitary data/messages, you need create a DataChannel which can be created after a PeerConnection got established. So far DataChannel are only available using a Commandline Parameter in Chrome 26 (+ without in Canary). Other WebRTC features like MediaStreams via getUserMedia() or solely PeerConnections are also available in Firefox & Opera (~ probably the reason it's not listed at caniuse.com). As you also still need an additional signaling channel, it's more complex to handle these connections compared to WebSockets + the current implementation doesn't provide reliable candidates. If you are still interested in P2P via WebRTC I would recommend you to take a look at PeerJS or PeerGaming. Hopefully in a few months PC/DC will get better support Quote Link to comment Share on other sites More sharing options...
ZippoLag Posted March 29, 2013 Share Posted March 29, 2013 @Autarc, well, I call this very promising!https://hacks.mozilla.org/2013/03/webrtc-data-channels-for-great-multiplayer/ Quote Link to comment Share on other sites More sharing options...
Autarc Posted April 1, 2013 Share Posted April 1, 2013 It is and shows what will be possible - just that the demo shows an specific use case with an hard coded implementation for their needs (as they used BananaBread, their emscripted port of Sauerbraten 2 compiled from native "C" code) With Chrome M28 reliable DataChannel should be available as well and with the latest changes in Firefox Nightly - we hopefully can work towards a cross-browser solution for gaming. As no one likes to use an additional server setup, the bootstrapping process + P2P brookering should be included in the initialization. So let's see how to tackle that as well as persistent network-data for late join & reconnects 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.