I remain unsure what to work on for my next book. There was much interest in Javascript gaming. I do not know it well enough to gauge how mature it is, but I know how to find out...
I am going to start with Gladius, the 3d gaming engine from Mozilla. First up, I clone it locally:
➜ repos git clone https://github.com/alankligman/gladius-core.git Cloning into 'gladius-core'...That takes a little while, but once I have the repository, it seems that I need to
make setup
:➜ gladius-core git:(develop) make setup make: *** No rule to make target `setup'. Stop.Or not.
Hrm... there's not even a
Makefile
in there (and what is a Jakefile?):➜ gladius-core git:(develop) ls -1 Jakefile lib LICENSE node_modules package.json README.md src tests toolsThe
Jakefile
seems to be a node thing, but there is no mention of setup. Gladius core bundles several NPM modules, but jake is not one of them:➜ gladius-core git:(develop) npm ls /home/chris/repos/gladius-core ├── amdefine@0.0.2 ├─┬ jshint@0.6.3 │ ├── argsparser@0.0.6 │ └─┬ minimatch@0.0.5 │ └── lru-cache@1.0.6 ├─┬ qunit@0.5.1 │ ├── argsparser@0.0.6 │ ├─┬ bunker@0.1.1 │ │ └─┬ burrito@0.2.11 │ │ ├── traverse@0.5.2 │ │ └── uglify-js@1.0.7 │ ├─┬ cli-table@0.0.1 │ │ └── colors@0.3.0 │ ├── tracejs@0.1.4 │ └── underscore@1.3.3 ├── requirejs@1.0.8 └── uglify-js@1.2.6Let's see if installing it globally (so that it can run as an executable) will work:
➜ gladius-core git:(develop) npm install -g jake npm http GET https://registry.npmjs.org/jake npm http 200 https://registry.npmjs.org/jake npm http GET https://registry.npmjs.org/jake/-/jake-0.2.33.tgz npm http 200 https://registry.npmjs.org/jake/-/jake-0.2.33.tgz /home/chris/local/node-v0.6.15/bin/jake -> /home/chris/local/node-v0.6.15/lib/node_modules/jake/bin/cli.js jake@0.2.33 /home/chris/local/node-v0.6.15/lib/node_modules/jakeAnd...
➜ gladius-core git:(develop) jake setup jake aborted. Error: Cannot find module 'jake' at Function._resolveFilename (module.js:332:11) (See full trace by running task with --trace)After running with
--trace
, I find that the error is coming from the Jakefile. Despite not being bundled with the rest of the NPM packages, it seems that I really do need it:➜ gladius-core git:(develop) npm install jake npm http GET https://registry.npmjs.org/jake npm http 304 https://registry.npmjs.org/jake npm WARN prefer global jake@0.2.33 should be installed with -g jake@0.2.33 ./node_modules/jakeYah, no kidding, NPM. I tried to install it globally and that didn't work.
After all that, it turns out that there is no
setup
task in the Jakefile or in the included files:➜ gladius-core git:(develop) jake setup jake aborted. Error: Unknown task "setup" at [object Object].nextPrereq (/home/chris/local/node-v0.6.15/lib/node_modules/jake/lib/task/task.js:154:19) (See full trace by running task with --trace)So what happens if I just run the default task?
➜ gladius-core git:(develop) jake jake aborted. TypeError: Object [object Object] has no method 'exec' at [object Object].action (/home/chris/repos/gladius-core/tools/jake-tasks/default.js:15:8) (See full trace by running task with --trace)Sigh. It seems that the "jake tasks" included in the Jakefile expect a locally installed
jake
. So I explicitly run that locally installed jake
and am able to build (but still not setup):➜ gladius-core git:(develop) ./node_modules/.bin/jake build Tracing dependencies for: ../tools/almond /home/chris/repos/gladius-core/dist/gladius-core.js ---------------- /home/chris/repos/gladius-core/lib/../tools/almond.js /home/chris/repos/gladius-core/lib/_math.js ... /home/chris/repos/gladius-core/lib/../src/core/engine.js /home/chris/repos/gladius-core/lib/../src/core/gladius-core.jsThat seems to have created a
gladius-code.js
in dist
:➜ gladius-core git:(develop) find . -mmin -10 . ./.git ./.git/index ./dist ./dist/gladius-core.js ./dist/gladius-core.min.jsSo now it's time to use this. Since I already seem to be in node-land, I install express.js globally and use that to generate an express.js site for myself:
cd $HOME/repos mkdir gladius-my cd gladius-my git init . npm install -g express express . npm installI comment out the default, "index" route in the generated
apps.js
:// ... // Routes // app.get('/', routes.index); // ...Instead, I copy the contents of the example page into
public/index.html
. I do update the <script>
tag to point to gladius-core.js
in express.js' /javascripts/
path:... <head> <script src='/javascripts/gladius-core.js'> </script> ...Lastly, I copy the generated
gladius-core.js
files into publics/javascripts
:cp ../gladius-core/dist/gladius-core.* public/javascriptsAnd...
That does not work. It seems that gladius has switched to requirejs for library loading. Bah! I like requirejs, but that marks one too many obstacles to overcome in one night. I will pick back up with this tomorrow.
Day #403
Hey Chris, thanks for giving this a try! I apologize for the lack of current documentation. I've recently added a new repo (https://github.com/gladiusjs/gladius) that has examples and built versions of the modules. Better docs and examples will be the focus for an upcoming release, and in the interim I've updated the README.md for the core module.
ReplyDeleteWe're going to be releasing 0.2 soon, but we're not quite finished refactoring some of the functionality from 0.1 (2d physics and user input) into extension modules yet.
/ack
Ah, cool. Thanks! I'll give that a try tonight :)
DeleteYou might want to remove the tutorial: https://github.com/gladiusjs/gladius-core/wiki/Tutorial as it only works with the old-develop branch.
Good catch! I've taken it down now.
DeleteI'm happy to answer questions in #games on irc.mozilla.org. Again, sorry for no docs :)