Nugget – A JavaScript Entity System
I have been interested in building a web-based game for some time now, and have been thinking for some time about how to make it work. After reading a number of articles about software patterns and architecture used in game development, I happened upon what appear to be a series of fairly widely-read articles on Entity Systems.
I think the best way to describe how this differs to traditional OO would be to say that it is a form of mass mixin/multiple inheritance. Entities have no properties or methods. Instead they are decorated with components that describe their characteristics. These components contain the properties that pertain to that characteristic: for example, a Health component will need to have a “hitpoints” property. By adding multiple component instances to an entity, you can imbue it with characteristics in a very dynamic way that would be clumsy to do with classical inheritance.
And so I created Nugget, an entity system implementation in JavaScript. It’s early days, but the core building blocks are there and I have a roadmap of features I’d like to add.
Check it out on GitHub.