Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I know HTML5 is great for web games, but I don't really know if it's possible to develop online games with multiple users, keeping everybody synchronized and handling logins, et cetera. Is it possible to do this?

share|improve this question

2 Answers 2

You can't write it with HTML5 alone. You will always need scripting and a server to handle communication between users, because of the security limits of browser scripting, and also to prevent cheating.

Many people have written multiplayer html5 games, even I have. The use of html5 itself is probably not the most important part of it. Most of the things needed (if not all) have been available in html 4.01 as well. The exception is canvas, but canvas is slower than svg, and svg was available in lots of browsers already.

I think what really spawned the "html5 game" mania is the ability to make server side apps in javascript. This means that all the client side programmers can suddenly make the entire system themselves, and they are usually the creative people when it comes to stuff like games. Not to mention that JS is so easy that even your grandma could program with it. Maybe.

Update after comment from OP:

A common architecture for a browser game would be

          Client                                     Server
|-----------------------|                   |---------------------|
View - input/output logic - Communication - Validation - Game World
              |                                              |
   client database (if needed)                    server database (if needed)

Or in terms of actual "languages":

  • Client view: HTML5 (possibly with angular.js, haven't tested how fast it is with LOTS going on yet. also check out raphael.js for "graphics")
  • Client logic: JavaScript (jquery/vapor/plain/whatever)
  • Client database: WebSQL (part of the HTML5 "suite" I suppose)
  • Communication: JSON (Javascript object notation, essentially serialized javascript objects) over socket.io (JS library for automatically detecting optimal communication protocols)
  • Server language: also JS (node.js if you have TONS of concurrent users on few cores, other solutions are available too)
  • Validation: just making sure your INCOMING game data (from client) is valid. Outgoing does not need to be checked, not even on client. It is assumed correct. Always.
  • Game World: a collection of VERIFIED data that is redistributed to all clients as they come in
  • Server database: couchdb, mongodb, whatever database that gives you raw json objects to work with.

There you are. A complete internet game written only using javascript and html. Lovely.

share|improve this answer
    
i find very interesting your answer, could you give me a little advice about which parts should i build (are most important) end to end and which technologies feed in each part, sorry about that, just trying to know how to build something an reliable. Thanks! –  arrrrgv Nov 9 '11 at 1:25
1  
+1, HTML5 is the rage, but what people attribute to it is mostly 4.01 functionality and JavaScript. Could I though ask you to not call JavaScript easy? It has got it's perks, but if you want to write real programs, you got to be a real programmer. JavaScript takes away the chores of variable declaration and memory management, but it does not make organizing your code and figuring algorithms and data structures any easier, and you definitely need a programmers mindset and experience for those tasks. –  eBusiness Nov 9 '11 at 9:09
    
@eBusiness what I mean by easy is that it's so condensed in terms of programming, and its use cases are documented to death. You can always find a tutorial or a function that does what you want. And it's easy to set up (you don't need to, it's already in the browser). –  Tor Valamo Nov 10 '11 at 3:19
    
@arrrrgv updated post with answer to your question –  Tor Valamo Nov 10 '11 at 3:37
1  
+1 for a nice answer, although I doubt the rise of HTML5 games has anything to do with server-side JavaScript. Strictly speaking JS isn't even part of HTML5. I think it's the new features like canvas, webGL, audio and video and local storage that give HTML5 games a boost. And of course the fact that it's new and hyped so everybody jumps the bandwagon. –  bummzack Nov 10 '11 at 7:11

Take a look at the article at http://smus.com/multiplayer-html5-games-with-node and also the source provided with the article. Note that this also uses JavaScript for networking.

share|improve this answer
2  
Please write "JavaScript" as a single word, to avoid confusion. –  Lohoris Nov 8 '11 at 8:47
    
One day, Node.js won't be necessary -- when cross-browser support for web sockets is widespread. –  Nick Wiggill Nov 8 '11 at 12:01
    
I don't see why cross-browser support for web sockets would change the need for a server component outside of any browser. You should always program a multiplayer game so that the clients connect to a central server, not directly client-to-client. –  jhocking Nov 8 '11 at 13:00
1  
Also check out NowJS (nowjs.com) –  Tim Holt Nov 8 '11 at 18:20
    
web sockets are inherently unsafe for any application, which is the reason why the planned implementation was abandoned by so many browsers. you can't allow an environment which gets access to "anywhere" and at the same time can take input from "anywhere". –  Tor Valamo Nov 8 '11 at 21:45

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.