
Ask HN: How do I build a browser game? - BookPage
I want to tinker on a dungeon crawler and want to know what the best way to do this in a browser is. I&#x27;m a backend engineer so am kind of hoping that it doesn&#x27;t _have_ to be some sort of Javascript.<p>Ideally:
 - Support rendering 2&#x2F;3d game
 - Network access for realtime multiplayer<p>Thanks!
======
LeftHandPath
You should look into “A Curious Expedition”, which is a commercially
successful Steam game based on web tech [0].

You will most likely have to use JavaScript, on the front end. You can do a
lot of neat graphical tricks these days - whether with Canvas, SVG’s, or
above-my-pay-grade wizardry.

What kind of back end engineer are you? Just curious since it sounds like you
don’t have a plan for multiplayer networking yet. Knowing what your skills are
would help determine what advice you need.

Edit: additionally, if you want to have a better time writing JavaScript, you
can use Gulp [1] and BabelJS [2] to compile ES6 into backwards-compatible JS.
Gulp is also helpful for streamlining other painful parts of web development -
worth reading through the docs.

Regarding multiplayer, it depends on how you plan to network. I am not sure
how people implement P2P networks these days. However, you could probably use
TCP/IP sockets (AF_INET) to take data from the client side and send it to a
central process (you will need asynchronous IO and you will probably want to
connect to the socket using JavaScript / web sockets). You could use a sock
file (AF_UNIX) to move data between different languages/scripts if you want
to, as well.

There is a very good intro to multiplayer networking here:
[https://gafferongames.com/post/what_every_programmer_needs_t...](https://gafferongames.com/post/what_every_programmer_needs_to_know_about_game_networking/)

[0]:
[https://news.ycombinator.com/item?id=17080985](https://news.ycombinator.com/item?id=17080985)

[1]: [https://gulpjs.com/](https://gulpjs.com/)

[2]: [https://github.com/babel/gulp-
babel/blob/master/README.md](https://github.com/babel/gulp-
babel/blob/master/README.md)

~~~
BookPage
Cool - thanks for the link, I'm checking it out now!

I'm a web services backend guy. Lots of Go and lots of traffic!

------
krapp
Most modern game engines will export to the web as javascript/WASM (at least I
know Godot and Unity will.) Construct2 is specifically intended for exporting
to the web. You can just treat "the browser" as another build target like
Windows, Linux or Android at this point, don't worry about it.

------
Aperocky
Use typescript and Pixi. Pretty easy to get started imo, I’m also a backend
engineer, here’s my progress after one day:
[http://aperocky.com/prehistoric](http://aperocky.com/prehistoric) Still a
long way to go but it’s quite a fast learning curve.

------
wowwhoknew
One section of this tutorial is 3.5 hours on how to make a basic clone of
agar.io

[https://www.udemy.com/course/socketio-with-websockets-the-
de...](https://www.udemy.com/course/socketio-with-websockets-the-details/)

I'd suggest checking out similar types of tutorials -- clones of popular
browser games, to see how different ones are built, and how to approach the
various aspects of creating one.

------
dorkinspace
If you haven't yet, I would look into Unity. You can write scripts in C# and
it comes with a ton of functionality out of the box. Unity can output webgl
and if you release the game and it is successful, it is generally quite easy
to release mobile versions without much work.

I've been working with Unity for years, feel free to ask any questions you
have!

------
topmonk
A lot of languages compile to javascript, including haskell, but I'd suggest
just bite the bullet, and use js directly. You'll save a lot of time and bang
your head against a lot less obscure issues.

You can use webgl for 3d graphics, and there are lots of examples on the web.

