A Vagrant VM for developing voxel.js games.
Install VirtualBox and Vagrant if not already available.
Create the voxeljs
VM instance:
vagrant up
Wait while the VM image in downloaded(first time only) and configured for node.js development.
The VM run a NGINX to serve games, examine the voxel.js getting started example at:
http://localhost:8080/games/example/
You can develop your own games on your host machine in the games
directory
and use the VM to compile and serve them.
To compile a game in games/new-game
, first ssh to the VM:
vagrant ssh
Then change to the directory location, shared from your host:
cd /vagrant/games/new-game
Install any necessary node modules from the packages.json
description:
npm install
Then compile the game using browserify:
browserify new-game.js > new-game-compiled.js
The generated Javascript can be fairly large so you may want to run it through uglifyjs.
uglifyjs -c new-game-compiled.js > new-game-compiled.min.js
HTML files in games/new-game
will be served from the VM via port forwarding
to your host machine at, e.g.:
http://localhost:8080/games/new-game/index.html
You can package and export the configured Vagrant VM into a new VM image:
vagrant package --output export/voxeljs.box
There is a Vagrantfile
in export
that can be used to create new VM instances
from this packaged VM.