8000 see doc/changelog; lots of major changes · GameJs/gamejs@bf8222e · GitHub
[go: up one dir, main page]

Skip to content

Commit bf8222e

Browse files
committed
see doc/changelog; lots of major changes
1 parent 30696a7 commit bf8222e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+2118
-2717
lines changed

.gitignore

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1-
gamejs.min.js
2-
docs/api/*
1+
node_modules/
2+
gamejs-*.js
3+
gamejs-*.min.js
4+
doc/api/*
5+
out/*
36
*~

.jshintrc

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"curly": true,
3+
"eqeqeq": false,
4+
"immed": true,
5+
"latedef": true,
6+
"newcap": true,
7+
"noarg": true,
8+
"sub": true,
9+
"undef": true,
10+
"boss": true,
11+
"eqnull": true,
12+
"node": true,
13+
"browser": true,
14+
// it's helpful for circular dependencies
15+
"latedef": false,
16+
"worker": true,
17+
"globals" : {
18+
//commonjs globals
19+
"module": false,
20+
"require": false,
21+
// qunit
22+
"QUnit": false,
23+
"qModule": false,
24+
"strictEqual": false,
25+
"deepEqual": false,
26+
"ok": false,
27+
"test": false,
28+
"asyncTest": false,
29+
"equal": true,
30+
// worker module loading; see gamejs.thread
31+
"__scripts": true,
32+
// why is this not already allowed with browser:true?
33+
"XMLDocument": true
34+
}
35+
}

Gruntfile.js

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
module.exports = function(grunt) {
2+
'use strict';
3+
4+
grunt.loadNpmTasks('grunt-contrib-jshint');
5+
grunt.loadNpmTasks('grunt-contrib-uglify');
6+
grunt.loadNpmTasks('grunt-contrib-concat');
7+
grunt.loadNpmTasks('grunt-exec');
8+
grunt.loadNpmTasks("grunt-contrib-clean");
9+
grunt.initConfig({
10+
pkg: grunt.file.readJSON('package.json'),
11+
12+
path : {
13+
// in
14+
srcDirectory: "src/",
15+
src: '<%= path.srcDirectory =>**/*.js',
16+
testSrc: 'tests/*js',
17+
yabble: 'utils/yabbler/yabble.js',
18+
// out
19+
buildout: 'out/',
20+
main : '<%= pkg.name %>-<%= pkg.version %>.js',
21+
min : '<%= pkg.name %>-<%= pkg.version %>-min.js',
22+
// for CJS wrapping
23+
yabbler: 'utils/yabbler/yabbler.js',
24+
rhino: 'utils/rhino-js.jar',
25+
exampleDirectories: 'examples/**'
26+
},
27+
uglify: {
28+
options: {
29+
mangle: false
30+
},
31+
build: {
32+
files: {
33+
'<%= path.min %>' : [ '<%= path.main %>' ]
34+
}
35+
}
36+
},
37+
jshint: {
38+
files: ['<%= path.src %>'], // for another day: , '<%= path.testSrc %>'
39+
options: {
40+
jshintrc: '.jshintrc',
41+
reporter: require('jshint-stylish'),
42+
globals: {
43+
jQuery: false,
44+
console: true,
45+
module: true,
46+
require: true
47+
}
48+
}
49+
},
50+
exec: {
51+
yabbler: "java -jar <%= path.rhino %> <%= path.yabbler %> -i <%= path.srcDirectory %> -o <%= path.buildout %>"
52+
},
53+
clean: ["<%= path.buildout %>"],
54+
concat: {
55+
dist: {
56+
src: ["<%= path.yabble %>", "<%= path.buildout %>**/*.js"],
57+
dest: "<%= path.main %>"
58+
}
59+
}
60+
});
61+
62+
grunt.registerTask('default', ['jshint', 'exec', 'concat', 'uglify:build', 'clean']);
63+
grunt.registerTask('build', ['exec', 'concat', 'uglify:build', 'clean']);
64+
};

README.md

+61-56
Original file line numberDiff line numberDiff line change
@@ -4,37 +4,58 @@ GameJs
44
GameJs is a JavaScript library for writing 2D games or other interactive
55
graphic applications for the HTML Canvas <http://gamejs.org>.
66

7-
Usage
8-
=========
7+
Game showcase: <http://gamejs.org/showcase.html>
8+
9+
Topics
10+
========
11+
12+
## Drawing on the screen
13+
14+
* gamejs.display
15+
* gamejs.image
16+
* gamejs.graphics
17+
* gamejs.font
18+
19+
## Mouse and keyboard
20+
21+
* gamejs.event
922

10-
Depending on how you got GameJs:
23+
## Audio
1124

12-
## Option 1: zip release
25+
* gamejs.audio
1326

14-
Extract the zip file and try the examples in the zip file over http://.
27+
### Kickstarting your game
1528

16-
## Option 2: Node package registry
29+
* gamejs.ready()
30+
* gamejs.preload()
31+
* gamejs.onTick()
1732

18-
After you installed gamejs, you can use a bundler like `browserify`
19-
to run your code on the client. Here's a small example:
33+
# Game logic
2034

21-
cd ~/my-web-game/
22-
npm install gamejs
23-
npm install -g browserify
24-
browserify ./main.js --out bundled.js
35+
* gamejs.animate
36+
* gamejs.tiledmap
37+
* gamejs.pathfinding
38+
* gamejs.collisionmask
2539

26-
## Option 3: using the git version
40+
## Advanced
2741

28-
You will have to build GameJs. Go to the GameJs directory and execute this
29-
in a unix shell, cygwin or in `git bash`:
42+
* gamejs.thread
43+
* gamejs.math.noise
3044

31-
$ ./bin/build.sh
45+
# Generally useful
3246

33-
This should create the `gamejs.min.js` file in the GameJs home directory.
47+
* gamejs.http
48+
* gamejs.math.*
49+
* gamejs.utils.*
3450

35-
Minimal example
51+
52+
53+
54+
Usage
3655
=================
3756

57+
### Standalone
58+
3859
Load the `gamejs.min.js` file and tell the module loader where your
3960
"main" module lies (usually "./javascript/main.js"):
4061

@@ -55,61 +76,45 @@ and start your game:
5576
....
5677
});
5778

58-
More Help
59-
===========
60-
61-
See the [GameJs Website](http://gamejs.org) for more help or drop us
62-
an email in the [Mailing List](http://groups.google.com/group/gamejs).
79+
### RequireJs/Browserify
6380

64-
Example application can be found in the `examples/` directory.
81+
GameJs is a CommonJs package published on NPM. You need to install the GameJs package:
6582

66-
Bundle your application for production
67-
==========================================================
83+
$ npm install gamejs
6884

69-
A bundled game:
85+
And something to run your modules in the browser, for example browserify:
7086

71-
* does not need to be served over http:// (unless it uses `SurfaceArray`)
72-
* has a smaller file size
73-
* has somewhat obfuscated code
87+
$ npm install -g browserify
7488

75-
To bundle all JavaScript files into one single file, use:
89+
Point browserify to your main module and produce a bundled JS file including GameJs and any other packages you use in your game:
7690

77-
$./bin/minify-app.sh ./path-to-your-app/javascript/
91+
$ browserify ./main.js --out bundled.js
7892

79-
You can also add a second argument `compress`. With `compress`, the resulting
80-
bundle file will be compressed for smaller file size as well as obfuscated.
93+
More Help
94+
===========
8195

82-
`minify-app.sh` will create the bundled file `app.min.js` in your app's
83-
`javascript` folder.
96+
See the [GameJs Website](http://gamejs.org) for more help or drop us
97+
an email in the [Mailing List](http://groups.google.com/group/gamejs).
8498

85-
With browserify
86-
----------------
99+
Example application can be found in the `examples/` directory.
87100

88-
If you already have nodejs installed, this might be convinient:
101+
Development - How to build
102+
===================
89103

90-
npm install -g browserify
91-
npm install gamejs
104+
GameJs consists of CommonJs modules in `./src/` which we build and jshint with grunt. If you don't already have node and npm, install those. You will also need `java` on your path for building the CommonJs files.
92105

106+
Install then grunt commandline interface:
93107

94-
GameJs Contribution
95-
===================
108+
$ npm install -g grunt-cli
96109

97-
Don't forget to `./bin/build.sh` when modifying the source.
98110

99-
All applications use a bundled JavaScript file which contains all the
100-
GameJs source files; thus if you modify the files below `./lib` your
101-
changes won't show up in the examples unless you re-build the source files
102-
with the `./bin/build.sh` command.
111+
In the GameJs folder you cloned, install the dependencies to build using npm:
103112

104-
Unit Tests
105-
--------------
113+
$ npm install
106114

107-
We use QUnit <https://github.com/jquery/qunit> for the GameJs unit tests. Execute
108-
the tests by opening `tests/index.html`.
115+
Build GameJs:
109116

110-
JsDoc
111-
----------
112-
For the JavaScript documentation system, RingoJs must be installed on your system.
117+
$ grunt
113118

114-
$ ./bin/create-jsdoc.sh
119+
This will create the `gamejs-VERSION.js` file and a minified `gamejs-VERSION.min.js` which you can use standalone in the browser, as demonstrated in the examples.
115120

bin/build.sh

-49
This file was deleted.

bin/minify-app.sh

-58
This file was deleted.

0 commit comments

Comments
 (0)
0