How to code an web-browser based multiplayer game?

10,734

Solution 1

The paradigm is a bit different. In a browser-based game, the game state is stored and computed on the server. All the user sees is a user interface that pulls data from this single game state.

Player 1 has a spaceship at location 34,29. He presses forward and goes to 35,30. This gets sent to the server with something like AJAX. Other players see this change when they query the web server for other players' locations. This location needs to be stored somewhere on that server in order for this to happen.

Think about the difference between Google docs and Microsoft Word. One has the document on your computer, the other is storing the document online and you are simply interacting with some distant HTTP server.

Solution 2

For the UI, you will probably get best results with Silverlight or Flash, followed by Java. As far as multiplayer interaction, you could use web services to send and receive data rather than UDP/socket communications.

Since you're already familiar with C#, you can leverage that knowledge with both Silverlight and web services so there's somewhat less to learn.

Share:
10,734
Rudi
Author by

Rudi

Updated on June 28, 2022

Comments

  • Rudi
    Rudi almost 2 years

    If I wanted to code a desktop-based game, I could pull some XNA code and UDP sockets and make a decent multiplayer game. I would have an extremely clear of how to code the game I wanted.

    But if I wanted to code a browser-based online multiplayer game, how would I do it? You can't use XNA....I've been looking at some questions and I'm seeing PHP and ASP.NET and Silverlight and Flash and Java as the alternative languages...I really don't understand how it works. I mean, for a desktop-based game, you're opening a UDP socket and accepting clients and transferring data, updating player states, drawing the results using XNA. But in a browser, how do you open a socket and stuff? How does that concept work, communicating to people in realtime through a web-browser. Any direction? I'm familiar with C#, and semi-familiar with Java. Never done any Flash, ASP.NET or Silverlight.