It’s been a while since Mozilla released BrowserQuest, a game built on nodejs with WebSockets. I love this retro style given to the game, I’ve always wanted to do that kind of game and now is a good chance to hack a popular game project and have some fun with it! :-)
Mozilla released the code in Github, but there are some cool stuff they couldn’t release yet, I hope they do it soon to create some new worlds easily.
I followed this two excellent sources from Dirk Krause to get it running in local or anywhere, but I think some novice people are still a bit confused about how to do it, so I will try to clarify just a couple things, you will need the instructions from Dirk anyway.
Getting the code from Github, the easiest way to get the client running is copying the shared directory inside the client one, executing it with http-server as explained before.
$ cd client $ cp -r ../shared . $ http-server Starting up http-server, serving ./ on port: 8080 Hit CTRL-C to stop the server
Now you can go to your browser to see it running.
If you click play nothing happens, we need to start the server.
$ node server/js/main.js [Wed Apr 18 2012 20:52:46 GMT+0200 (CEST)] INFO Starting BrowserQuest game server... [Wed Apr 18 2012 20:52:46 GMT+0200 (CEST)] INFO world1 created (capacity: 200 players). [Wed Apr 18 2012 20:52:46 GMT+0200 (CEST)] INFO Server is listening on port 8000
You could modify client and server ports in the config_local.json file, inside both directories (client and server), but using this approach (http-server module) is not neccessary to change client’s port.
Server will search for config in two places:
var defaultConfigPath = './server/config.json', customConfigPath = './server/config_local.json';
There is a config.json by default, binding the server to port 8000, so if you don’t care about ports by now there’s nothing to worry about.
That’s it, have fun!