Git Product home page Git Product logo

grape2d's Introduction

Grape2D - 1.3.0-alpha

Be aware that it is in its early stages, and a lot may change, and a lot will be added.

JavaScript 2D Game Engine

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.

Docs

Right now there is only available API documentation, generated through JSDoc.

Usage

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>

Building Grape2D

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.

Contributing to Grape2D

  1. Have a GitHub account
  2. Fork the repository
  3. Check the [code style guideline]
  4. Make changes to your clone of the repository
  5. Submit a pull request

Licence

This project is under the MIT License

grape2d's People

Contributors

ruipgil avatar

Stargazers

João Sardinha avatar

Watchers

James Cloos avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.