Ask HN: How do I build a browser game?
I want to tinker on a dungeon crawler and want to know what the best way to do this in a browser is. I'm a backend engineer so am kind of hoping that it doesn't _have_ to be some sort of Javascript.
Ideally: - Support rendering 2/3d game - Network access for realtime multiplayer
Thanks!
8 comments
[ 3.0 ms ] story [ 28.7 ms ] threadYou 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...
[0]: https://news.ycombinator.com/item?id=17080985
[1]: https://gulpjs.com/
[2]: https://github.com/babel/gulp-babel/blob/master/README.md
I'm a web services backend guy. Lots of Go and lots of traffic!
You can use webgl for 3d graphics, and there are lots of examples on the web.
https://www.udemy.com/course/socketio-with-websockets-the-de...
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.
I've been working with Unity for years, feel free to ask any questions you have!