Dima.js

An open-source, high-performance, HTML5 game framework with an emphasis on an entity-system architecture.

Download Dima.js v0.1.0 Learn To Make Your Own Games

About

Dima.js is a game framework for making games in Javascript and HTML5. Dima makes building games of medium to large scale easier than ever.

At its core is a super light-weight framework that provides the structure for your games, and it's fine if that's all you choose to use but Dima also comes with (if you so choose) a large collection of modules that include various components and systems for common game development needs. The core is an entity-system architecture framework that let's you avoid the common pitfalls of a traditional OOP inheritence based game by separating out your game into entities, components, and systems.


Why would I want to use an entity-system architecture over a traditional OOP-based one?

Others have already written some amazing articles online about the numerous advantages of an Entity-System architecture that if you haven't read would be a good introduction.

To summarize entity system architectures let you be entirely flexible with the entities of your game without having to know their final structure.


Features


Code Sample


Defining a Component

dima.component('velocity', function () {
  var velocityComponent = function () {
    this.x = 0;
    this.y = 0;
  };
  velocityComponent.prototype.set = function(x,y) {
    this.x = x;
    this.y = y;
  };
  return velocityComponent;
});

Attaching a Component To an Entity

var playerEntity = dima.createEntity();
dima.attachComponentTo('velocity', playerEntity)
  .set(1,0);

Defining a System

dima.system('Movement', function () {
    return {
      requires: ['transform', 'velocity'],
      process: function (collection) {
        var transform, velocity;
        for(var i = 0; i < collection.length ; i += 2) {
          transform = collection[i];
          velocity = collection[i+1];
          transform.x += velocity.x;
          transform.y += velocity.y;
        }
      }
    };
  });

Open Source

Dima.js is an entirely open source project that you can contribute to in a variety of ways: