Be aware that it is in its early stages, and a lot may change, and a lot will be added.
Grape2D is a complete and very modular game engine for 2D graphics, but with lot of room for improvement. Providing unique features in the "javascript world". Grape2D is great for beginners, but even better for developers that are more experienced, because of it's modularity. Because of it's careful design (based in a OO approach) almost everything can be changed to fit your needs, with little effort integrating it back into the structure.
Right now there is only available API documentation, generated through JSDoc.
Include Grape2D into your HTML page from the build directory. The next step is up to you. I personally recommend extending Grape2D.SimpleGame or implement the interface Grape2D.Game. If you're not certain the best method to extends a function or implement a class see [code style guideline].
In this example we extend the SimpleGame class.
<script>
/**
* @extends {Grape2D.SimpleGame}
* @constructor
*/
var MyGameLoop = function(renderer, scene, camera) {
Grape2D.SimpleGame.call(this, renderer, scene, camera);
};
MyGameLoop.prototype = Object.create(Grape2D.SimpleGame.prototype);
/**
* @override
*/
MyGameLoop.prototype.setup = function() {
this.getScene().getMap().add(
new Grape2D.Object2D({
position: new Grape2D.Vector(),
boundingBox: new Grape2D.AABB({
width: 10,
height: 10
}),
texture: Grape2D.Texture.createFromImage('imgs/an_image.jpg')
})
);
map.rebuild();
};
/**
* @override
*/
MyGameLoop.prototype.update = function(dt) {
Grape2D.SimpleGame.prototype.update.call(this, dt);
};
var mgl = new MyGameLoop({
new Grape2D.CanvasRenderer({
width: Grape2D.utils.getDocumentSize().width,
height: Grape2D.utils.getDocumentSize().height
}),
new Grape2D.SceneLayer({
map: new Grape2D.SimpleMap()
}),
new Grape2D.Camera({
scale: new Grape2D.Vector(5, 5)
})
});
window.onload = function(){
mgl.getRenderer().appendToDOMElement(document.body);
mgl.setup();
mgl.start();
}
</script>
Grape2D is easy to build and only requires some pre-requirements:
nodejs
+npm
- closure compiler, with the environment variable
CLOSURE_PATH
pointing to the installation folder, not to the bin folder. See grunt-closure-compiler page for more details. - run
installDev.bat
, it downloads the required dependencies for grunt.
With that, in the utils folder, run:
grunt
to build it,grunt doc
to build just the API documentation,grunt test
to run QUnit tests,grunt all
to build it, build the API documentation and run the tests.
- Have a GitHub account
- Fork the repository
- Check the [code style guideline]
- Make changes to your clone of the repository
- Submit a pull request
This project is under the MIT License