Search code examples
html5-canvasmultiplayer

Adding multiplayer to HTML5 canvas game


Let's say I have similar simple HTML5 canvas game in website: LINK

What are the options to add multiplayer to this? By that I mean one user can play with other.

  • Tutorial?
  • Blog post I didn't find?
  • Library specially for that?
  • Or you know to say few works about that?

First there's a Play button which then "keeps loading" when clicked until anyone else presses the button too & it automatically hooks up these 2 users - very simple construction, nothing too complicated.

I've done my homework & I didn't find anything useful.


Solution

  • You have some options, but for a basic tic-tac-toe game I'd use a database.

    Connect the clients to the database, updating the move they make from both sides and voila, you've got yourself a (slow) multiplayer game.

    Alternatively, check out this tutorial to try it with javascript (ajax): https://jadendreamer.wordpress.com/2012/04/26/ajax-tutorial-2-player-tic-tac-toe-game-no-database-required/