Running BrowserQuest in Windows 7 x64

BrowserQuest

IMPORTANT: I’m moving this blog to buildfailure.co. This post is outdated, please visit http://www.buildfailure.co/running-browserquest-in-windows-7-x64/ :)

Have you heard? Some pretty cool guys made a completely functional MMO RPG that runs on the browser! This HTML5 goodness is called BrowserQuest. It’s JavaScript heavy: both the client and server use the same programming language, with NodeJS on the backend.

In this tutorial, I’ll walk you through the process of getting BrowserQuest and running it locally on your computer, with Windows 7 x64; which presents a few problems that you shouldn’t find if you do it on a Windows x86, much less a Linux machine. This tutorial should work for Windows 7 x86 too. I assume you know the basic server stuff, the theory is the same for Microsoft IIS, Apache, etc.

Note: for all big downloads, I suggest getting the offline installers with jDownloader instead of the web installers. This way you’ll make sure you don’t screw up if you lose internet connection while running a web installer, and won’t have to start downloads again if the installation fails.

If you haven’t already, download and install NodeJS. At the time of writting, the current public release is v0.8.14, but you’ll need v0.9.2 or newer for this to work on a Windows x64, so grab one of the releases in nodejs.org/dist/, such as v0.9.3.

BrowserQuest uses several third-party packages. One of them, websocket, requires you to install Python and MS VC++. If you don’t, you’ll get an error when installing the packages: Native code compile failed.

Download and install Python 2.7.3, and add it to Windows Path (Start > Computer > Right Click > Properties > Advanced System Settings > Environment Variables… >  System Variables > PATH > Edit).

The Fun Part

Update/Notice: you may not need to follow the steps in this section. All this is required to compile native extensions for the websocket package, but “this module DOES NOT REQUIRE the native components and will still work without them, though not quite as efficiently.”. Feel free to skip straight to downloading the source code (in the next section).

Yes, it’s sarcastic. This is going to be a pain in the neck, but we’ll get through it somehow. Download and install Microsoft Visual C++ 2010 Express, and after it’s done, follow with the SP1 (alt. iso, much heavier but more reliable). This one will take a while, so go make yourself some coffee while you wait. You may also need the Windows SDK for Windows 7 and .Net 4 (alt. web install). If downloading the ISO, make sure you get the GRMSDKX_EN_DVD.iso one. The others are for Windows x86 and Itanium. If the SDK installation fails (with a completely cryptic and useless error message), there’s a few things to try. Make sure you uncheck the C++ Redistributables and the Compilers from the SDK installation, we will install those separatedly. Finally, you will probably need to install the Microsoft Visual C++ 2010 Service Pack 1 Compiler Update for the Windows SDK 7.1.

Time to get the code!

Download the BrowserQuest source code from github, and extract it locally wherever you wish on your machine.

Now you’ll need to install several packages required by BQ. Node Package Manager will make this task really easy if you followed the previous steps. Open the windows console, change dir to where you have the BQ source, and enter the following command:
> npm install underscore log bison websocket websocket-server sanitizer memcache
Hit enter and wait. NPM will start downloading, installing and configuring each of these packages automagically.

Starting the Game

In windows console, start the game server with the following command:
...\BrowserQuest > node server/js/main.js
Now go to the client directory, and install the http-server module which will serve the client files, same as any usual web server:
...\BrowserQuest\client > npm install -g http-server
Now navigate to ...\BrowserQuest\client\config and look for a config_local.json-dist file. Rename it to config_local.json (we just removed the -dist), and open it in your favourite text editor. You should see something like

{
"host": "Set local dev websocket host here",
"port": 8000,
"dispatcher": false
}

We’ll change the host to “127.0.0.1”. Save and close. Same goes for config_build.json-dist, rename and edit.
Now copy the shared folder to the client, you should get a directory structure such as ...\BrowserQuest\client\shared\js.
Lastly, we need to start the http server we installed previously:
...\BrowserQuest\client > http-server
That’s it! Your server and client should be running now. Open 127.0.0.1:8080 to see if the page is properly served, you should see the same you see when you load the game from the official BQ page. To check if the game server is running correctly, you can load 127.0.0.1:8000/status in the browser, it will return a JSON array containing the number of players in all instanced worlds on this game server.

And now, I think you well deserve some time to play the game! See how far you can get, I managed to obtain a Magic Sword!

I hope this tutorial helped you. If you still get errors or can’t understand part of the tutorial, don’t hesitate to ask here!

Sources
http://stackoverflow.com/questions/10238034/installing-and-running-browserquest-on-ubuntu
http://cjihrig.com/blog/websockets-in-node-js-0-8-6-for-windows-7/
https://github.com/voodootikigod/node-serialport/issues/90
https://github.com/TooTallNate/node-gyp
http://connect.microsoft.com/VisualStudio/feedback/details/683852/fail-to-install-windows-sdk-to-add-x64-cross-compiler-to-visual-c-2010-express-running-on-x86-pc-based

Advertisements

9 thoughts on “Running BrowserQuest in Windows 7 x64

  1. Pingback: Culturally Impacting: Greenheart’s Game Dev Tycoon, Piracy and The Irony. | Build Failure

    • Lumiere, are you sure you started both servers? There’s one for the game’s website (which, it seems, you have started properly), and another for the actual game, which listens to the websockets connections. Is the game server starting without problems?

    • I’m glad it worked!
      I’ll be writing a few more tutorials soon, I’ve been digging through Browser Quest’s code and implementing MongoDB, but there’s a lot to be done, so it might take a little while :)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s