MCPcopy Index your code
hub / github.com/GameJs/gamejs

github.com/GameJs/gamejs @v1.0.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v1.0.0 ↗ · + Follow
121 symbols 273 edges 59 files 8 documented · 7%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

GameJs

GameJs is a JavaScript library for writing 2D games or other interactive graphic applications for the HTML Canvas http://gamejs.org.

Usage

Depending on how you got GameJs:

Option 1: zip release

Extract the zip file and try the examples in the zip file over http://.

Option 2: Node package registry

After you installed gamejs, you can use a bundler like browserify to run your code on the client. Here's a small example:

cd ~/my-web-game/
npm install gamejs
npm install -g browswerify
browserify ./main.js --out bundled.js

Option 3: using the git version

You will have to build GameJs. Go to the GameJs directory and execute this in a unix shell, cygwin or in git bash:

$ ./bin/build.sh

This should create the gamejs.min.js file in the GameJs home directory.

Minimal example

Load the gamejs.min.js file tell the module loader where your "main" module lies (usually "./javascript/main.js"):

<script src="https://github.com/GameJs/gamejs/raw/v1.0.0/public/gamejs.min.js"></script>
<script>
    require.setModuleRoot('./javascript/');
    require.run('main')
</script>

And inside "./javascript/main.js", you can require gamejs and start your game:

var gamejs = require('gamejs');
gamejs.ready(function() {
   var display = gamejs.display.setMode([600, 400]);
   display.blit(myImage);
   ....
});

More Help

See the GameJs Website for more help or drop us an email in the Mailing List.

Check the docs folder of your GameJs installation.

Example application can be found in the examples/ directory.

Bundle your application for production

A bundled game:

  • does not need to be served over http:// (unless it uses SurfaceArray)
  • has a smaller file size
  • has somewhat obfuscated code

To bundle all JavaScript files into one single file, use:

$./bin/minify-app.sh ./path-to-your-app/javascript/

You can also add a second argument compress. With compress, the resulting bundle file will be compressed for smaller file size as well as obfuscated.

minify-app.sh will create the bundled file app.min.js in your app's javascript folder.

With browserify

If you already have nodejs installed, this might be convinient:

npm install -g browserify npm install gamejs

GameJs Contribution

Don't forget to ./bin/build.sh when modifying the source.

All applications use a bundled JavaScript file which contains all the GameJs source files; thus if you modify the files below ./lib your changes won't show up in the examples unless you re-build the source files with the ./bin/build.sh command.

Unit Tests

We use QUnit https://github.com/jquery/qunit for the GameJs unit tests. Execute the tests by opening tests/index.html.

JsDoc

For the JavaScript documentation system, RingoJs must be installed on your system.

$ ./bin/create-jsdoc.sh

Core symbols most depended-on inside this repo

require
called by 110
utils/yabbler/yabble.js
escapeText
called by 19
utils/qunit/qunit.js
id
called by 16
utils/qunit/qunit.js
extend
called by 13
utils/qunit/qunit.js
getModule
called by 12
utils/yabbler/yabble.js
runLoggingCallbacks
called by 11
utils/qunit/qunit.js
sourceFromStacktrace
called by 8
utils/qunit/qunit.js
getCanvas
called by 8
lib/gamejs/display.js

Shape

Function 121

Languages

TypeScript100%

Modules by API surface

utils/qunit/qunit.js32 symbols
utils/yabbler/yabble.js20 symbols
lib/gamejs/event.js7 symbols
utils/yabbler/yabbler.js6 symbols
lib/gamejs/pathfinding/astar.js6 symbols
lib/gamejs.js6 symbols
lib/gamejs/mixer.js5 symbols
lib/gamejs/image.js5 symbols
lib/gamejs/display.js5 symbols
lib/gamejs/worker.js4 symbols
lib/gamejs/tmx.js4 symbols
utils/qunit/qunit-canvas.js2 symbols

For agents

$ claude mcp add gamejs \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact