Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to code an web-browser based multiplayer game?

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.

like image 586
Rudi Avatar asked Dec 01 '25 06:12

Rudi


1 Answers

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.

like image 95
Donald Miner Avatar answered Dec 02 '25 19:12

Donald Miner



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!