BrowserQuest : Jeu multi-joueurs en HTML5
Ordinateur Serveur : Distribution : Wheezy Raspbian
Ordinateur Client : Distribution : Ubuntu 12.04 LTS
I) Installation sur le Raspberry Pi Serveur :
1) Répertoire de travail :
pi@framboise ~ $ mkdir -p JEUX/BROWSERQUEST pi@framboise ~ $ cd JEUX/BROWSERQUEST/ pi@framboise ~/JEUX/BROWSERQUEST $
2) Installation de dépendance :
pi@framboise ~/JEUX/BROWSERQUEST $ sudo apt-get install git-core curl build-essential openssl libssl-dev
3) Installation de NodeJS et de NPM :
– Téléchargement :
pi@framboise ~/JEUX/BROWSERQUEST $ wget http://nodejs.org/dist/v0.10.25/node-v0.10.25.tar.gz
– Décompression :
pi@framboise ~/JEUX/BROWSERQUEST $ tar xvfz node-v0.10.25.tar.gz pi@framboise ~/JEUX/BROWSERQUEST $ cd node-v0.10.25/ pi@framboise ~/JEUX/BROWSERQUEST/node-v0.10.25 $
– Configuration :
pi@framboise ~/JEUX/BROWSERQUEST/node-v0.10.25 $ ./configure
– Compilation :
pi@framboise ~/JEUX/BROWSERQUEST/node-v0.10.25 $ make
– Installation :
pi@framboise ~/JEUX/BROWSERQUEST/node-v0.10.25 $ sudo make install
– Vérification :
pi@framboise ~/JEUX/BROWSERQUEST/node-v0.10.25 $ node --version v0.10.25
4) Installation des modules :
pi@framboise ~/JEUX/BROWSERQUEST/node-v0.10.25 $ cd .. pi@framboise ~/JEUX/BROWSERQUEST $ sudo npm install express underscore log bison websocket websocket-server sanitizer memcache
5) Télécharger BrowserQuest :
pi@framboise ~/JEUX/BROWSERQUEST $ git clone https://github.com/mozilla/BrowserQuest.git pi@framboise ~/JEUX/BROWSERQUEST $ cd BrowserQuest/
6) Fichier de configuration :
pi@framboise ~/JEUX/BROWSERQUEST/BrowserQuest $ cp client/config/config_build.json-dist client/config/config_build.json
Ouvrir :
client/config/config_build.json
Remplacer tout par :
{ "host": "127.0.0.1", "port": 8000 }
pi@framboise ~/JEUX/BROWSERQUEST/BrowserQuest $ cp client/config/config_local.json-dist client/config/config_local.json
Ouvrir :
client/config/config_local.json
Remplacer tout par :
{ "host": "127.0.0.1", "port": 8000, "dispatcher": false }
pi@framboise ~/JEUX/BROWSERQUEST/BrowserQuest $ cp server/config_local.json-dist server/config_local.json
7) Compilation :
pi@framboise ~/JEUX/BROWSERQUEST/BrowserQuest $ cd bin/ pi@framboise ~/JEUX/BROWSERQUEST/BrowserQuest/bin $ ./build.sh pi@framboise ~/JEUX/BROWSERQUEST/BrowserQuest/bin $ cd ..
8) Copie des fichiers compilés :
pi@framboise ~/JEUX/BROWSERQUEST/BrowserQuest $ cp -Rf shared/ client-build/ pi@framboise ~/JEUX/BROWSERQUEST/BrowserQuest $ cp -Rf client/* client-build/
9) Démarrage du serveur :
pi@framboise ~/JEUX/BROWSERQUEST/BrowserQuest $ node server/js/main.js [Thu Feb 06 2014 22:44:14 GMT+0100 (CET)] INFO Starting BrowserQuest game server... path.exists is now called `fs.exists`. [Thu Feb 06 2014 22:44:14 GMT+0100 (CET)] INFO world1 created (capacity: 200 players). [Thu Feb 06 2014 22:44:14 GMT+0100 (CET)] INFO world2 created (capacity: 200 players). [Thu Feb 06 2014 22:44:14 GMT+0100 (CET)] INFO world3 created (capacity: 200 players). [Thu Feb 06 2014 22:44:14 GMT+0100 (CET)] INFO world4 created (capacity: 200 players). [Thu Feb 06 2014 22:44:14 GMT+0100 (CET)] INFO world5 created (capacity: 200 players). [Thu Feb 06 2014 22:44:14 GMT+0100 (CET)] INFO Server is listening on port 8000
Status du serveur : http://192.168.1.12:8000/status
Résultat :
[0,0,0,0,0]
Si 1 joueur :
[1,0,0,0,0]
10) Répertoire de travail du client BrowserQuest :
Dans un autre terminal :
pi@framboise ~ $ cd ~/JEUX/BROWSERQUEST/BrowserQuest/client-build/ pi@framboise ~/JEUX/BROWSERQUEST/BrowserQuest/client-build $
11) Installation du module : http-server :
pi@framboise ~/JEUX/BROWSERQUEST/BrowserQuest/client-build $ sudo npm install -g http-server
12) Lancement du serveur du client :
pi@framboise ~/JEUX/BROWSERQUEST/BrowserQuest/client-build $ http-server
13) Sur l’ordinateur Client :
Tester avec Firefox 26.0
Lien du jeu : http://192.168.1.12:8080
14) Pendant le jeu, sortie log du serveur :
... [Thu Feb 06 2014 23:01:24 GMT+0100 (CET)] DEBUG Received: 0,sa,21,60 [Thu Feb 06 2014 23:01:24 GMT+0100 (CET)] INFO sa has joined world1 [Thu Feb 06 2014 23:01:25 GMT+0100 (CET)] DEBUG Received: 20,90,924,925,926,927,1020,1021,1022,1120,1121,1122,1220,1221,1222,1320,1321,1322,1820,1821,84195,87195,815222,818209,837200,841195,847195,867220,870197,873197,8154138 [Thu Feb 06 2014 23:01:25 GMT+0100 (CET)] DEBUG Pushed 30 new spawns to 543 [Thu Feb 06 2014 23:01:34 GMT+0100 (CET)] DEBUG Received: 4,39,210 [Thu Feb 06 2014 23:01:34 GMT+0100 (CET)] DEBUG sa is moving to (39, 210). [Thu Feb 06 2014 23:01:34 GMT+0100 (CET)] DEBUG Received: 26,2 [Thu Feb 06 2014 23:01:36 GMT+0100 (CET)] DEBUG Received: 4,40,207 [Thu Feb 06 2014 23:01:36 GMT+0100 (CET)] DEBUG sa is moving to (40, 207). [Thu Feb 06 2014 23:01:37 GMT+0100 (CET)] DEBUG Received: 4,45,208 [Thu Feb 06 2014 23:01:37 GMT+0100 (CET)] DEBUG sa is moving to (45, 208). [Thu Feb 06 2014 23:02:02 GMT+0100 (CET)] DEBUG Received: 4,46,209 [Thu Feb 06 2014 23:02:02 GMT+0100 (CET)] DEBUG sa is moving to (46, 209). [Thu Feb 06 2014 23:02:07 GMT+0100 (CET)] DEBUG Received: 4,38,208 [Thu Feb 06 2014 23:02:07 GMT+0100 (CET)] DEBUG sa is moving to (38, 208). [Thu Feb 06 2014 23:02:10 GMT+0100 (CET)] DEBUG Received: 4,40,209 [Thu Feb 06 2014 23:02:10 GMT+0100 (CET)] DEBUG sa is moving to (40, 209). [Thu Feb 06 2014 23:04:05 GMT+0100 (CET)] INFO sa has left the game. [Thu Feb 06 2014 23:04:05 GMT+0100 (CET)] DEBUG Removed warrior : 543 ...
I’m getting an error
root@raspberrypi:/var/rajah/BrowserQuest/server/js# node main.js
module.js:340
throw err;
^
Error: Cannot find module ‘underscore’
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object. (/var/rajah/BrowserQuest/server/js/metrics.js:3:9)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)